【问题标题】:j_security_check only works on fresh pagej_security_check 仅适用于新页面
【发布时间】:2014-10-13 15:40:55
【问题描述】:

我们有一个j_security 登录表单,只能在新页面上使用。意味着没有历史记录,没有以前的登录,也没有失败的登录。如果页面是新的并且用户输入了错误的密码,则会出现正确的错误。但是当用户在那里输入正确的密码后,会出现HTTP Status 400 - Invalid direct reference to form login page 并暂停登录,直到浏览器的历史记录被清除并重新加载页面。

这是登录代码。 Dropdown.getXML 会根据开发环境更改 url。在这种情况下,它会将其更改为正确的开发。

<form id="login" name="j_security_form" action="<%out.write(Dropdown.getXML("https://www.example.com/public/j_security_check")); %>" method="post" accept-charset="UTF-8">
            <strong>Account Login</strong><br>
                Username:<br>
                    <input type="text" name="j_username"><br>
                Password:<br>
                    <input type="password" name="j_password"><br>
                <br>
                    <input type="submit" value="Login"><br>
                <br>
                    New users <a href="../user_registration.jsp">register here</a><br>
                    <a href="../forgot_password.jsp">Forgot password?</a>
                    <input type="hidden" name="auth_mode" value="basic">        
                <script>
                var newloc = document.location.href;
                newloc =newloc.replace('index.jsp','index.jsp');
                document.write('<input type="hidden" name="orig_url" value="'+newloc+'">');
                </script>
        </form>

请帮助我们找到这个问题的答案!感谢您的帮助。

【问题讨论】:

    标签: java jsp security jboss jaas


    【解决方案1】:

    您不应该直接访问您在web.xml 中指定为登录页面的页面。此登录页面是一个特殊页面,当用户尝试访问安全资源但尚未登录时,他将被重定向到该页面。

    如果您需要直接访问登录页面或在未受保护的页面中显示登录表单,您可以在 servlet 中实现编程登录、管理 bean (jsf) 等。

    Using Programmatic Security with Web Applications

    【讨论】:

      猜你喜欢
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多