【问题标题】:j_security_check not redirecting to angular with # hash keyj_security_check 不使用# hash key 重定向到角度
【发布时间】:2016-05-25 09:43:37
【问题描述】:

我有一个带有基于表单的身份验证和基于 Angular 的客户端的 jboss Web 应用程序。 场景:

  1. 我转到http://localhost:8082/my-app/#/dashboard,会话超时
  2. 它重定向到登录页面 (login.jsp)。我输入用户名和密码,然后提交。
  3. 它将我发送到 localhost:8080/my-app,不是 http://localhost:8082/my-app/#/dashboard

j_security_check 应该在成功登录后返回请求的 url。但它会忽略 # 后缀吗?

login.jsp

    <form id="loginForm" method="post" action="/my-app/j_security_check">
          <input id="usernameInput" name="j_username" type="hidden" />
           <input id="password" name="j_password" type="password" required="">
           <button type="submit">
                Sign In
              </button>
          </form>

web.xml

<web-app 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"
         version="2.4">

  <display-name>OpTierUI Application </display-name>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>CSS</web-resource-name>
      <url-pattern>/styles/*</url-pattern>
      <url-pattern>/fonts/*</url-pattern>
      <url-pattern>/assets/images/*</url-pattern>
    </web-resource-collection>
  </security-constraint>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Protected Area</web-resource-name>
      <description>These pages are only accessible by authorized administrators.</description>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
  </security-constraint>
  <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
      <form-login-page>/login.jsp</form-login-page>
      <form-error-page>/login.jsp?error=error</form-error-page>
    </form-login-config>
  </login-config>
  <error-page>
    <error-code>403</error-code>
    <location>/login.jsp?unauthorized=unauthorized</location>
  </error-page>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>

【问题讨论】:

    标签: angularjs jsp redirect web.xml j-security-check


    【解决方案1】:

    浏览器不会将#hash 密钥或之后的任何内容发送到服务器。 #hash key 只能被浏览器识别。

    【讨论】:

      猜你喜欢
      • 2012-03-20
      • 2015-12-14
      • 2016-09-16
      • 1970-01-01
      • 2016-02-05
      • 2020-11-29
      • 2020-11-28
      • 1970-01-01
      • 2011-09-02
      相关资源
      最近更新 更多