﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-The Spark of Thinking-文章分类-Webwork2</title><link>http://www.blogjava.net/sharkafeng/category/13538.html</link><description>Focus on Eclipse Tools.</description><language>zh-cn</language><lastBuildDate>Thu, 01 Mar 2007 15:37:40 GMT</lastBuildDate><pubDate>Thu, 01 Mar 2007 15:37:40 GMT</pubDate><ttl>60</ttl><item><title>Webwork2执行流程</title><link>http://www.blogjava.net/sharkafeng/articles/60559.html</link><dc:creator>The Spark of Thinking</dc:creator><author>The Spark of Thinking</author><pubDate>Fri, 28 Jul 2006 06:18:00 GMT</pubDate><guid>http://www.blogjava.net/sharkafeng/articles/60559.html</guid><wfw:comment>http://www.blogjava.net/sharkafeng/comments/60559.html</wfw:comment><comments>http://www.blogjava.net/sharkafeng/articles/60559.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/sharkafeng/comments/commentRss/60559.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/sharkafeng/services/trackbacks/60559.html</trackback:ping><description><![CDATA[
		<ol>
				<li>服务启动的时候，ServletDispatcher 通过DefaultConfiguration 先加载webwork.properties 和default.properties ，并查找webwork.properties 中webwork.custom.properties 配置的其他属性文件加载。加载完毕后再通过属性中配置的webwork.custom.i18n.resources 加载国际化资源文件供以后使用。之后再查找webwork.configuration 属性看是否用户指定了自己的Configuration 实现，如果有就用用户自己的Configuration 实现，否则返回WebWork自己的实现（DelegatingConfiguration）。大部分情况下，使用WebWork 自己的实现已经足够，用户不需要自己去实现一个Configuration，除非你想加载XML 等格式的配置文件。 
</li>
				<li>每一个以*.action 结尾的请求，都会被映射到ServletDispatcher 调度器的service 方法进行处理。首先把init 方法读取的encoding 、locale 配置设置到request 和response 中，之后对request 进行判断，看是否属于多类型参数（multipart/formdata）的请求，如果是，则根据WebWrok 配置信息对request 进行相应的包装。包装完request 对象后，service 方法又调用了ServletDispatche日、 自身的serviceAction 方法，在该方法中调用了createContextMap创建Action 上下文，并通过ActionProxyFactory 创建ActionProxy 实例，ActionProxy又会调用ConfigurationManager 去读取XWork 的配置信息并获得当前请求的Action 的所有配置信息，之后遍历执行这个Action 对应的所有拦截器，然后执行Action 对应的方法（默认的是execute），再根据Action 执行返回的值去调用执行相应的Result（返回结果处理）的方法做一定的处理后，把输出结果返回给客户端。</li>
		</ol>
		<ul>
				<li>ActionContext<br />xwork框架的ActionContext是Action执行时的上下文，存放Action执行时需要用到的对象。在使用webwork时，其中放有Parameter、Session、ServletContext、Locale等信息。这样，webwork负责将Servlet相关数据转换为与ServletAPI无关的Map对象（即ActionContext），使得xwork的Action实现与web层、逻辑层与表现层的解耦。 
</li>
				<li>
						<div align="left" twffan="done">ServletActionContext<br />提供直接与Servlet容器交互的途径。通过它，可以取得HttpServletRequest、HttpServletResponse 、ServletConfig、ServletContext、PageContext 对象。但是，使用ServletActionContext意味着Action与ServletAPI的紧密耦合。</div>
				</li>
		</ul>
<img src ="http://www.blogjava.net/sharkafeng/aggbug/60559.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/sharkafeng/" target="_blank">The Spark of Thinking</a> 2006-07-28 14:18 <a href="http://www.blogjava.net/sharkafeng/articles/60559.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>