![](/img/trans.png)
[英]Spring 3.5. When user login then logout and try to login once again he get an error about user\pass
[英]Logout redirects user to login page again after user tries login again when session timeouts
为了避免登录页面和ViewExpiredException
会话超时,我使用以下命令将保存状态保存到客户端:
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
我注意到会话超时时,我尝试再次登录,除非出现此错误,否则我将被重定向到我访问的最后一页:
ERROR [org.apache.catalina.connector.CoyoteAdapter] An exception or
error occurred in the container during the request processing
java.lang.ArrayIndexOutOfBoundsException
ERROR [org.apache.coyote.http11.Http11Processor] Error finishing response
java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method)
从而将用户重定向到主页。 我还没弄清楚怎么做,但我认为现在还可以。 我现在的问题是,当用户在会话超时时单击要注销的链接并尝试再次登录时,他将再次重定向到登录页面。 我的观察是,由于没有遇到上述错误,因此它继续执行注销链接应执行的操作,即执行Identity.logout()
并将用户重定向到登录页面。 我认为导致重定向到登录页面的人是pages.xml中的这一行。
<navigation from-action="#{identity.logout}">
<end-conversation before-redirect="true" />
<redirect view-id="/identifier.xhtml" />
</navigation>
但是删除线并不能解决问题。 可能的解决方案是:
在会话超时并且用户尝试再次登录时不执行注销
当会话超时并且用户尝试再次登录并将用户引导到首页时,停止继续执行每种方法,就像重新登录一样(我认为这也可以防止Http11Processor
的ArrayIndexOutOfBoundsException
)
您能提出什么最佳方法来实施此解决方案? 我正在使用jboss-soa 4.3.0
和jsf 1.1
这是我像您这样的项目中的解决方案。 它正在使用Servlet Filter
。
假定=>登录过程之后,用户对象可能与ID为“ loginUser”的会话保持连接。
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
HttpSession session = httpRequest.getSession();
User user = (User) session.getAttribute("loginUser");
if (user != null) {
filterChain.doFilter(servletRequest, servletResponse);
} else {
httpResponse.sendRedirect(httpRequest.getContextPath() + "/login.xhtml");
}
}
我设法通过删除components.xml中的这些行来执行解决方案2:
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
<action execute="#{identity.tryLogin}"/>
</event>
<event type="org.jboss.seam.security.loginSuccessful">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
现在,每次会话到期并且用户尝试登录时,他都会被重定向到主页。 这足以解决我的注销问题,并立即删除ArrayIndexOutOfBoundsException
,除非他们想恢复用户访问的最后一页。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.