我正在嘗試基於表單的身份驗證,但我無法弄清楚爲什麼,在登錄頁面輸入正確的用戶名/密碼後,它會將我重定向到錯誤頁面而不是index.jsp
。基於表單的身份驗證 - 成功驗證後重定向到錯誤頁面(Tomcat 7.0.4)
當我鍵入:
http://localhost:8080/<context>/secure/index.jsp
我得到的登錄頁面。但是,當我輸入用戶/密碼(經理/經理)時,它將我帶到error.html
而不是index.jsp
。
WEB.XML:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>FormBasedAuthentication</display-name>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>role1</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>SecurePages</web-resource-name>
<description>Security constraint for JSP resources</description>
<url-pattern>/secure/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>role1</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
TOMCAT-USER.XML:
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-status"/>
<role rolename="manager-jmx"/>
<role rolename="role1"/>
<user username="manager" password="manager" roles="role1"/>
</tomcat-users>
什麼是您的應用程序服務器? – zaerymoghaddam
@moghaddam Tomcat7 – yapkm01