为了避免与Servlet API耦合在一起,方便Action类做单元测试,Struts 2对HttpServletRequest、HttpSession和ServletContext进行了封装,构造了三个Map对象来替代这三种对象,在Action中,直接使用HttpServletRequest、.....
分类:
其他好文 时间:
2014-09-15 19:23:19
阅读次数:
160
获取单值Object obj = ((Object[])ActionContext.getContext().getParameters().get("parentCuetomerId"))[0]获取集合Object[] objs = (Object[]) ActionContext.getCont...
分类:
其他好文 时间:
2014-09-10 19:21:50
阅读次数:
203
ActionContext ActionContext是Action的上下文,Struts2自动在其中保存了一些在Action执行过程中所需的对象,比如session, parameters, locale等。Struts2会根据每个执行HTTP请求的线程来创建对应的ActionContext,即一...
分类:
其他好文 时间:
2014-09-09 17:40:39
阅读次数:
163
用一张表格来总结:变量从ActionContext中获得生命周期用Ongl来读取值使用ServletConfigInterceptor来注入ActionContext类静态方法ActionContext. getContext()一次Http请求使用“#”加上key,如“#name”无法注入Val....
分类:
其他好文 时间:
2014-09-09 17:35:09
阅读次数:
296
/** 修改页面 */ public String editUI() { //准备回显得数据 Role role = roleService.getById(id); ActionContext.getContext().getValueStack().push(role);//下面的方...
分类:
其他好文 时间:
2014-09-04 20:53:10
阅读次数:
234
ActionContext
每个请求的处理都在一个独立的线程中,每个线程都有一个ActionContext对象,它包含了ValueStack和HttpServletRequest的东西。
Struts把所有的变量统一放在一个方便的地方,而不是将数据传来传去,这个东西就是ValueStack。它贯穿于整个处理流程,所以拦截器和视图层都可以操作ValueStack中的内容。一般通过OGNL...
分类:
其他好文 时间:
2014-09-03 22:46:57
阅读次数:
238
public String showAllArticleForPage() throws Exception{
HttpServletRequest request = ServletActionContext.getRequest();
String username=(String) ActionContext.getContext().getSession().get("user");
...
分类:
其他好文 时间:
2014-09-03 13:05:26
阅读次数:
208
package com.sise.action;import java.util.Map;import com.opensymphony.xwork2.Action;import com.opensymphony.xwork2.ActionContext;import com.opensymphon...
分类:
其他好文 时间:
2014-09-03 10:50:16
阅读次数:
197
首先要先获取HttpServletResponse对象
在struts2如何获取这里就不详细说了 有几种办法 不会的自己百度
我这里用的是
HttpServletResponse response = (HttpServletResponse) ActionContext.getContext().get(ServletActionContext.HTTP_RESPONSE);
//下...
分类:
Web程序 时间:
2014-09-02 19:55:35
阅读次数:
206
Struts2 在项目中用到的核心是拦截器interceptor,OGNL(Object Graph navigation Language)对象图导航语言(用来操作ValueStack里面的数据),Value Stack和ActionContext。strut2是基于WebWork,WebWork...
分类:
其他好文 时间:
2014-09-01 13:49:53
阅读次数:
492