Action中的session值的失效与哪几方面有关???我在这里面用session存放了一个user的信息
public ActionForward check(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
response.setContentType("text/html;charset=utf-8");
request.getCharacterEncoding();
int id = 0;//   
UserLoginForm userLoginForm = (UserLoginForm) form;
List listcheck = new UserLoginService().checkUser(userLoginForm
.getUserName(), userLoginForm.getUserPass());
if (listcheck.size() != 0) {// 即如果登录成功
Userlogin user = (Userlogin) listcheck.get(0);
request.getSession().setAttribute("user", user);
id = user.getUsertype().getTypeId();
request.setAttribute("userLogin", user);
List leftparentLeft = new ParentService().checkparentById(id);
request.setAttribute("leftparentLeft", leftparentLeft);
return mapping.findForward("main");
} else {
request.setAttribute("fail", "123");
return mapping.findForward("loginfail");
}
}
但在这里面过段时间后就取不到了,时间在web.xml我已经设置成了
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>20</session-timeout>
</session-config>在其他的Action有时能取到,但一会就取不到了。帮忙解决一下,谢谢。