- 浏览: 186649 次
- 性别:
- 来自: 湖州
最新评论
-
l_zh_y:
非常 感谢
spket-1.6.11.zip破解版-eclipse插件links方式安装包 -
nookiehuihui:
非常感谢 一直在找破解的
spket-1.6.11.zip破解版-eclipse插件links方式安装包 -
bangyan2003:
要破解的 这东西?????
spket-1.6.11.zip破解版-eclipse插件links方式安装包 -
oyhf521:
非常感谢啊,顶,就一个字
spket-1.6.11.zip破解版-eclipse插件links方式安装包 -
xiezhuogang:
哈哈,谢谢了
spket-1.6.11.zip破解版-eclipse插件links方式安装包
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
String param = filterConfig.getInitParameter("packages");
String packages = "com.opensymphony.webwork.static template com.opensymphony.webwork.interceptor.debugging";
if (param != null) {
packages = param + " " + packages;
}
this.pathPrefixes = parse(packages);
DispatcherUtils.initialize(filterConfig.getServletContext());
}
ps:
DispatcherUtils进行了初始化,参数为servletcontext,采用 单例模式。
初始化方法中对packages进行了parse,目前我还不知道在哪需要用到
DispatcherUtils.initialize(filterConfig.getServletContext());
方法中进行了xwork的一些处理 text的loacl处理 ObjectFactory的初始化处理
webwork 的Configuration 的处理
总而言之,这一句简简单单的initialize方法,让我们根据web.xml中得到的基本信息中初始化了
application级别的相关东西,xwork所需要的全局的东西也得到初始化,webwork 下的config目录也发挥了他的作用
接下来,我们看看dofilter 这个起核心作用的方法
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
ServletContext servletContext = filterConfig.getServletContext();
// prepare the request no matter what - this ensures that the proper character encoding
// is used before invoking the mapper (see WW-9127)
DispatcherUtils du = DispatcherUtils.getInstance();
du.prepare(request, response);//正如这个方法名字一样进行locale、encoding以及特殊request parameters设置
try {
// Wrap request first, just in case it is multipart/form-data
// parameters might not be accessible through before encoding (ww-1278)
request = du.wrapRequest(request, servletContext);//对request进行包装
} catch (IOException e) {
String message = "Could not wrap servlet request with MultipartRequestWrapper!";
LOG.error(message, e);
throw new ServletException(message, e);
}
ActionMapperIF mapper = ActionMapperFactory.getMapper();//得到action的mapper
ActionMapping mapping = mapper.getMapping(request);// 得到action 的 mapping
if (mapping == null) {
// there is no action in this request, should we look for a static resource?
String resourcePath = RequestUtils.getServletPath(request);
if ("".equals(resourcePath) && null != request.getPathInfo()) {
resourcePath = request.getPathInfo();
}
if ("true".equals(Configuration.get(WebWorkConstants.WEBWORK_SERVE_STATIC_CONTENT))
&& resourcePath.startsWith("/webwork")) {
String name = resourcePath.substring("/webwork".length());
findStaticResource(name, response);
} else {
// this is a normal request, let it pass through
chain.doFilter(request, response);
}
// WW did its job here
return;
}
Object o = null;
try {
//setupContainer(request);
o = beforeActionInvocation(request, servletContext);
//最核心的方法,这里通过ActionProxyFactory生成ActionProxy(包含actioninvocation actioncontext的信息供拦截器配合result一起发挥ww和xwork的作用)
du.serviceAction(request, response, servletContext, mapping);
} finally {
afterActionInvocation(request, servletContext, o);
ActionContext.setContext(null);
}
}
这里注意几个factory的使用
1、ActionMapperFactory
ActionMapperIF mapper = ActionMapperFactory.getMapper();ActionMapping mapping = mapper.getMapping(request);
2、ActionProxyFactory
ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, name, extraContext, true, false);
得到该action的代理实例
特别要注意的actioninvocation也是在proxy生成的时候初始化好了,
proxy包含了 action所需要的所有东西,完成接下来的一系列工作,
感觉其实这些东西也是比较简单的,通过传引用解决了哪需要就设置到哪去这种方式,不用担心对象的内容改变。
du.serviceAction(request, response, servletContext, mapping);该方法如下:
public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
Map extraContext = createContextMap(request, response, mapping, context);
// If there was a previous value stack, then create a new copy and pass it in to be used by the new Action
OgnlValueStack stack = (OgnlValueStack) request.getAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY);
if (stack != null) {
extraContext.put(ActionContext.VALUE_STACK, new OgnlValueStack(stack));
}
try {
String namespace = mapping.getNamespace();
String name = mapping.getName();
String method = mapping.getMethod();
String id = request.getParameter(XWorkContinuationConfig.CONTINUE_PARAM);
if (id != null) {
// remove the continue key from the params - we don't want to bother setting
// on the value stack since we know it won't work. Besides, this breaks devMode!
Map params = (Map) extraContext.get(ActionContext.PARAMETERS);
params.remove(XWorkContinuationConfig.CONTINUE_PARAM);
// and now put the key in the context to be picked up later by XWork
extraContext.put(XWorkContinuationConfig.CONTINUE_KEY, id);
}
ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, name, extraContext, true, false);
proxy.setMethod(method);
request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, proxy.getInvocation().getStack());
// if the ActionMapping says to go straight to a result, do it!
if (mapping.getResult() != null) {
Result result = mapping.getResult();
result.execute(proxy.getInvocation());
} else {
proxy.execute();
}
// If there was a previous value stack then set it back onto the request
if (stack != null) {
request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, stack);
}
} catch (ConfigurationException e) {
LOG.error("Could not find action", e);
sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e);
} catch (Exception e) {
String msg = "Could not execute action";
LOG.error(msg, e);
sendError(request, response, context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
}
}
ps:webwork 其实是一个很简单的框架,实现servlet协议,包装httpreques\httpresponse\httpsession\\httpservletcontext进行解偶,通过xwork来处理核心逻辑,不过感觉其包结构不够好,框架虽简单新手入门却不容易。
发表评论
-
Json-lib & Hibernate: tips and hints
2009-09-02 22:47 991Json-lib & Hibernate: tips ... -
poi EXCEL
2009-02-19 08:35 910http://www.iteye.com/problems/7 ... -
webwork中Excel导出几种方式
2009-02-16 09:06 26701.WebWork中自定义result视图使用POI生成Exc ... -
自定义表单系统构想
2008-08-15 23:48 2659近来淘宝,发现淘宝网的商品查询做得很细致,很灵活,能通过产品各 ... -
jdbexplor 开发环境的搭建
2008-07-17 09:16 877把jdbexplor导入到了eclipse的开发环境设置,主要 ... -
答复: spring的mvc中的controller不是线程安全的..
2008-05-24 16:08 1786针对对象而言, 所谓是否“线程安全”,是指“具有可写的成员变量 ... -
java文件操作的一个摘录,还没看先存在这了
2008-05-21 20:01 11921. /** 2. * 给定一个源文件路径 ... -
spring.jar 里面为什么有不属于自己的包见图
2008-05-15 21:22 1211spring.jar 里面为什么有不属于自己的包 见图 ... -
想学习下spring的源码碰到好多问题啊
2008-05-08 17:25 16331、首先我下载了最新的 spring-framework-2. ... -
计算机的二进制带符号运算为什么用0表示正数1表示负数
2007-06-06 23:03 14964以8b为例对比如下:(谁能给我补补课,说说为什么是正0负1,按 ... -
java 基础
2007-04-17 15:19 1432break,continue http://www.webas ... -
学习资料
2007-04-09 15:50 63http://www.51testing.com/html/9 ... -
java]二进制和十进制的相互转换
2007-04-24 09:20 7179[java]进制转换 Integer.parseInt( ... -
设计模式学习(一)单例模式
2007-04-02 21:51 159http://www.iteye.com/topic/6017 ... -
Java 语言中的函数编程
2007-03-20 11:05 1636引用: http://www-128.ibm.com/dev ... -
{求Goodidea} webwork如何实现returnUrl
2007-03-02 20:37 4835就拿普通的一个实体的crud来说吧 第一个页面 ,是一个 实 ... -
Re: 有关 EJB3,无状态会话Bean 与 Spring 依赖注入 Singleton 的困惑!
2007-02-07 09:17 2030引用 这就是我的困惑所在。我们都知道,可以用无状态的 Sing ... -
springside学习中遇到的问题
2006-12-29 13:56 11272本想发在新手版上,又怕没人回答,麻烦指点后再帮我投新手贴,谢谢 ...
相关推荐
webwork底层源码,用于webwork框架设计
剖析 Webwork 源码-Along-Anatomy Webwork Source Code_V0.9.pdf
webWork 源码, struts2 学习和提升的必需资料, 提供有详细的文档说明, 示例代码, 源码, 能够使初学者学而有味, 老手们也是学而不乏. 更是在开发过程中的帮助一把手.
剖析 Webwork
剖析Webwork源码 深入了解Webwork
webwork源码,struts2.0核心技术
webwork的源码和tomcat的源码,可以借鉴一下
struts2已经大有飞入寻常百姓家的趋势了,大家都知struts2其实是webwork2项目来的。所以我们还是从webwork得源码来看一下struts2的端倪~ <br>详细讲解核心类
webwork源码下载
非常好的Webwork2入门资料,OpenDoc出品
webwork-2.2.5源码包下载
xwork源代码(webwork源代码,xwork source,)xwork源代码(webwork源代码,xwork source,)
Webwork入门 WebWork入门教程[创建你第一个WebWork action]
详细介绍了,webwork2的配置及action映射,验证框架等,里面有jar包,源代码
详细的介绍了webwork的使用机制和标签的归类使用
WEBWORK的配置
这是webwork1的jar包,还有webwork-2.2.7.jar和webwork-src-2.2.7.jar
webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程
用的是webwork+spring+hibernate,在网上看了不少webwork+spring的配制方式,大多都是老的配制方式,比如2.1.7的,webwork2.2.4新加了很多功能,和spring的配制也简单了很多,我做了一个简单的登录程序,webwork2.2.4...
博文链接:https://melet.iteye.com/blog/102700