大家好!请问在Struts2中,如何通过一个自定义的Interceptor向结果页面传值。比如,我用一个Interceptor做权限校验,发现权限不合法时不执行Action直接返回结果页面,然后在结果页面中用<s:proptery>标签来读取结果并显示。请指教!
解决方案 »
- 急求!关于UEditor struts2获取UEditor的时候 将&转义了
- 谁帮忙做一个读取xml的页面
- 请教:为什么java向oracle中存图片,大于10k就不行
- 又是一个我不会,但觉得挺简单的问题,进来帮下哈~
- spring中的hibernate事务问题 急!
- 用response.getOutPutStream()流返回excel问题
- ActionError和ActionMessage有什么区别?
- win 7 32位旗舰版 iis 7.5 于tomcat 6整合一直不成功!谁整合成功过?请教!
- 菜鸟送分,问在JB下在jsp中调用applet的相对路径的写法。
- 怎么搭建jsp服务器,新手,在线等
- 再问,Tomcat配置SQLServer连接池问题!!!
- 关于结果集ResultSet
方法1:ServletActionContext.getContext().put(key, value);
方法2:ActionContext.getContext().put(key, value)
ActionInvocation ai;
ai.getInvocationContext().getContext().put(key, value);
public class MyInterceptor extends AbstractInterceptor { public String intercept(ActionInvocation arg0) throws Exception { ActionContext ac = (ActionContext) arg0.getInvocationContext();
Map map = ac.getSession(); if (map == null) {
ac.put("notLand", "没有权限登录!");
return "error";
} else {
return arg0.invoke();
}
}
}2.jsp显示:
<s:property value="#notLand" />
ServletActionContext.getContext()
ActionContext.getContext()ActionInvocation ai;
ai.getInvocationContext()
ai.getInvocationContext().getContext()以上4个方法的返回结果是不是都是当前的ActionContext,只是取得的方式不一样,有没有效率、好坏等之分?
另外
ai.getInvocationContext()
ai.getInvocationContext().getContext()
这两个的返回结果是否有什么不同呢?
ai.getInvocationContext().getContext() :返回ActionContext实例。