今天对struts2增加一个判断session 是否过期的过滤器,结果导致所有action获取不到request值和用户请求的值. public String intercept(ActionInvocation actionInvocation) throws Exception {
System.out.println("判断用户是否过期");
Map<String, Object> session = actionInvocation.getInvocationContext()
.getSession();
LoginUser user = (LoginUser) session.get("loginUser");
String invoke = "";
if (user != null) {
System.out.println("正常." + user.getName());
invoke = actionInvocation.invoke();
} else {
System.out.println("不正常.");
Map request = (Map) actionInvocation
.getInvocationContext().getContext().get("request");
request.put("message", "登陆超时,请重新登陆。");
invoke = "reLogin";
}
return invoke;
}
public String fplQuery() throws Exception {
PageBean pageBean = new PageBean();
pageBean.setPageNum(request);//
public class Freig***yAction extends ActionSupport implements
ServletRequestAware, ModelDriven<Frei****Model> {在获取request对象的时候就抛null指针异常modeldriven除了前面一个action给set进去的值外,用户页面输入的值在modeldriven里面都为空.各位有没什么好的建议
System.out.println("判断用户是否过期");
Map<String, Object> session = actionInvocation.getInvocationContext()
.getSession();
LoginUser user = (LoginUser) session.get("loginUser");
String invoke = "";
if (user != null) {
System.out.println("正常." + user.getName());
invoke = actionInvocation.invoke();
} else {
System.out.println("不正常.");
Map request = (Map) actionInvocation
.getInvocationContext().getContext().get("request");
request.put("message", "登陆超时,请重新登陆。");
invoke = "reLogin";
}
return invoke;
}
public String fplQuery() throws Exception {
PageBean pageBean = new PageBean();
pageBean.setPageNum(request);//
public class Freig***yAction extends ActionSupport implements
ServletRequestAware, ModelDriven<Frei****Model> {在获取request对象的时候就抛null指针异常modeldriven除了前面一个action给set进去的值外,用户页面输入的值在modeldriven里面都为空.各位有没什么好的建议
解决方案 »
- dynamic web project重新发布到tomcat后不更新
- JDBC调用ORACLE存储过程出现错误,说PACKAGE内的存储过程未定义,请大家帮忙看一下
- httpservletrequest.setattribute和servletrequest.setattribute的区别
- java里比较基础的几个问题,请教
- eclipse一呼百应的方法
- jsp中关于两个select数据从数据库中取出并关联的问题
- weblogic platform 出现corrupted.Error code 望大侠相助理
- JMS具体是做什么的?是用来发邮件的么?
- 为什么resin3.0.8里,javabean的class必须放到/WEB-INF/classes目录
- 搭建了个SpringMvc的框架,使用Controller跳转时可以跳转到jsp类型的页面,html的确报404.
- 在线等。。关于 spring-security框架 登录的问题。。。
- Ibatis:SqlMapClient和DaoManager的区别
class="com.web.interceptor.UserValidatorInterceptor" />
<interceptor-stack name="validateUser">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="userValidator" /> </interceptor-stack> <package name="desktop" namespace="/" extends="">
<action name="desktopAction" class="desktopAction">
<result name="inArticle">/desktop/inArticle.jsp</result>
<interceptor-ref name="userValidator"/>
</action>
</package>
要把defaultStack系统的堆栈放在里面否则效果一样.