【发布时间】:2016-05-25 09:43:37
【问题描述】:
我有一个带有基于表单的身份验证和基于 Angular 的客户端的 jboss Web 应用程序。 场景:
- 我转到http://localhost:8082/my-app/#/dashboard,会话超时
- 它重定向到登录页面 (login.jsp)。我输入用户名和密码,然后提交。
- 它将我发送到 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