java - 使用 Tomcat 进行基于表单的身份验证

标签 java authentication tomcat struts-1

我需要在 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/

相关文章:

eclipse 4.3 中的 Tomcat 服务器存在路径问题

spring - 不能用spring和tomcat运行昆德拉

java - 如何设置tomcat应用服务器的home执行目录?

java - 在mac上运行ant安装netbeans : Buildfile: build. xml不存在!构建失败

java - 我的就地堆排序代码有什么问题

node.js - Express res.render 不适用于 Angular 路由

来自 cron 作业的 svn 身份验证(osx 10.7)

Java,将 double 舍入到小数点后两位(舍入到 0.05)

java - 我是否需要同步 invokeAll 调用的结果?

azure - 将自定义声明 "samaccountname"添加到 Azure 广告中时出现问题