该行:
<form-login-page>/success.jsp</form-login-page>
在
web.xml实际上应该是:
<form-login-page>/login.jsp</form-login-page>
这告诉tomcat,每当您到达受保护的页面时,登录表单都位于
login.jsp。缺少的是实际上需要进行身份验证才能看到的受保护页面的定义:
<security-constraint> <web-resource-collection> <web-resource-name> Entire Application </web-resource-name> <url-pattern>/success.jsp</url-pattern> </web-resource-collection> <auth-constraint> <role-name> 'the name of the group with access' </role-name> </auth-constraint></security-constraint>
以及的定义
realm,这是您的用户名/密码对(tomcat
realm)的存储库。
进行这些更改后,您
http://localhost:8080/succes.jsp应将其重定向到登录页面,并在将有效凭据集发送到
/success.jsp并将无效凭据集发送到
/error.jsp。



