我需要在 Struts 1.3.10 + Tomcat 中进行基于表单的身份验证
根据我的理解,一旦提交登录凭据,容器将与 tomcat-users.xml
交叉检查凭据,并基于此转发到
成功页面或错误页面。
登录.jsp
<form action="j_security_check" method="post">
<input type="text" name="j_username"/>
<input type="password" name="j_password"/>
<input type="submit"/>
</form>
web.xml
<login-config>
<form-login-check>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-check>
</login-config>
怀疑:
如果提供了有效的凭据,服务器如何进入成功页面?
因为在 login.jsp
acion 中,我给出了 j_security_check
,而不是转发到成功页面的正常操作。
最佳答案
身份验证由服务器提供,因此您不应该关心服务器是如何执行此操作的。请求的资源URL由服务器存储在某处,然后引导您进入登录页面,如果登录成功则返回请求的资源。
When a user submits their name and password, the server determines if the user name and password are those of an authorized user and, if authorized, sends the requested web resource. If the topic of authentication is new to you, please refer to the section Specifying an Authentication Mechanism.
关于java - 使用 Tomcat 进行基于表单的身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35098082/