我正在开发一个使用Spring Hibernate开发的java web应用程序。当应用程序部署在Glassfish-3.1.2和Tomcat-6/7上时,应用程序工作良好。但是,当应用程序部署在AppFog(网站托管应用程序)上时,它无法举行会话,即用户登录到应用程序,但是当他单击任何链接时,他被重定向回登录页面。
之所以会发生这种情况,是因为我创建了一个拦截器(SessionInterceptor)来检查每个请求中的用户会话,这些请求将应用程序重定向到登录页面,以防会话过期。下面是我在我的preHandle类的SessionInterceptor ()方法中编写的代码:
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
HttpSession session = request.getSession();
if(!(handler instanceof HomeController || handler instanceof ForgetPasswordController)) {
if(session.getAttribute("user") == null) {
response.sendRedirect(request.getContextPath()+"/"+redirectMapping+"?msg=e");
return false;
} else {
return true;
}
} else {
return true;
}
}我不知道为什么会在AppFog上发生这种情况。任何帮助都很感激。提前感谢!
发布于 2013-09-19 14:53:45
AppFog支持哪种servlet规范?如果我没有错,servlet >=2.3支持spring拦截器
https://stackoverflow.com/questions/18894317
复制相似问题