まず第一に、いくつかの詳細:web.xmlビューで以下のようにセキュリティを構成しました。
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/formLoginPage.html</form-login-page>
<form-error-page>/formErrorPage.html</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>MyBeerApp</web-resource-name>
<url-pattern>/web/form.html</url-pattern>
<url-pattern>/SelectBeer.do</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>member</role-name>
</auth-constraint>
<user-data-constraint>
<!--transport-guarantee>CONFIDENTIAL</transport-guarantee-->
</user-data-constraint>
</security-constraint>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>member</role-name>
</security-role>
<security-role>
<role-name>guest</role-name>
</security-role>
以下のようにtomcat-user.xmlで:プレーンコピーをclipboardprintに表示しますか?
<role rolename="member"/>
<role rolename="guest"/>
<user username="vgarg2" password="tomcat" roles="member,guest" />
<user username="vgarg3" password="tomcat" roles="guest" />
ファイルの場所は次のとおりです。プレーンコピーをclipboardprintに表示しますか?
<TOMCAT_HOME>\Beer-v1\index.html
<TOMCAT_HOME>\Beer-v1\web\form.html
<TOMCAT_HOME>\Beer-v1\WEB-INF\web.xml
<TOMCAT_HOME>\Beer-v1\WEB-INF\classes\...
form.htmlの内容:
プレーンコピーをclipboardprintに表示しますか?
<html>
<body>
<h1 align="center">Beer Selection Page</h1>
<form method="POST" action="../SelectBeer.do">
Select Beer Characteristics
Color : <select name="color1" size="1">
<option value="light1">Light</option>
<option value="amber1">Amber</option>
<option value="brown1">Brown</option>
<option value="dark1">Dark</option>
</select>
<br/>
Can sizes:
<input type="checkbox" name="sizes" value="12oz">12 oz</input>
<input type="checkbox" name="sizes" value="24oz">24 oz</input>
<input type="checkbox" name="sizes" value="36oz">36 oz</input>
<br/>
<center>
<input type="submit"/>
</center>
</form>
</body>
<html>
今私の問題は、「http:// localhost:8080 / Beer-v1 / web/form.html」へのリクエストが制約されていないことです。/web/form.htmlから「http:// localhost:8080 / Beer-v1 / SelectBeer.do」にリクエストを送信すると、認証がチェックされ、ID/パスワード情報が要求されます。
セキュリティ制約を無効にすると、アプリは正常に動作します。
ここで何が問題になっていますか?