最近在做一个移动的CRM项目,发现从4A系统跳转到CRM系统,2边都是测试环境session不会丢失。但是到了2边都是正式系统时,4A的用户信息已经传到CRM。CRM也保存了用户信息。短信也能正常收到。但是到跳转页面的时候,session丢失,直接到超时界面。代码如下:
//Action代码
ActionContext.getContext().getSession().put(WebConstant.SESSION_ATTRIBUTE_USER, user);
ActionContext.getContext().getSession().put("contactphone", operVO.getContactphone());
LoginMACTable.getInstance().put(user);//更新操作员工号对应的MAC地址
doGetSMSAndSend();//发送短信给操作员
return "index";
//过滤器代码
public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) rsp;
String currentURL = request.getRequestURI();
String requestType = request.getHeader("x-requested-with");
//非ajax访问
if(null==requestType || !requestType.equals("XMLHttpRequest"))
{
if (isProtectedResource(currentURL)) {
User user = (User) request.getSession().getAttribute(WebConstant.SESSION_ATTRIBUTE_USER);
if (user != null) {
} else {request.getSession().invalidate();
String contextPath = request.getContextPath();
String errorStr = "top.location.href='" + contextPath + NO_SIGNON_PAGE + "';";
PrintWriter pw = response.getWriter();
pw.write(errorStr);
return;
}
//struts配置
<global-results>
<!-- 当返回login视图名时,转入/login.jsp页面 -->
<result name="login">/login.jsp</result>
<result name="login2">/login2.jsp</result>
<result name="logout">/login.jsp</result>
<result name="index" type="redirect">/index.jsp</result>
</global-results>
/index.jsp