Struts2對WebWork的改進
最近下載了struts2.0.6,可真大,解壓后大約150M,仔細看了一下,跑了其自帶幾個demo,并看了一下代碼,可以說基本和webwork2一樣的,核心基本沒改,感覺就修改了包名,說是struts和webwork合并,個人覺得是webwork利用struts這個招牌尋找市場,struts利用webwork2獲得重生,因為在struts2基本看不到struts1的影子了??上?,目前沒有關(guān)于struts2的書籍,感覺自帶的文檔排版比較亂(就和webwork2的一樣),很難尋找想要的信息,不過可以看webwork in action, 其實只要看了webwork in action的前五章,就可以理解struts2的架構(gòu)了。
struts2對webwork的改進之處:
1.webwork.properties文件中變量現(xiàn)在可以配置在下列文件(這是struts2自帶文檔中的說的):
struts-default.xml
struts-plugin.xml(在每個plugin的jar包中)
struts.xml(用constant元素)
struts.properties
(沒有默認文件,可選,與webwork.properties文件相似,每個項目可以有這個文件)
web.xml
下面是struts2自帶文檔中的示例
- Constant Example (struts.xml)
- <struts>
- <constant name="struts.devMode" value="true" />
- ...
- </struts>Constant Example (struts.properties)
- struts.devMode = trueConstant Example (web.xml)
- <web-app id="WebApp_9" version="2.4"
- xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
- http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <filter>
- <filter-name>struts</filter-name>
- <filter-class>org.apache.struts2.dispatcher.FilterDispatcher
- </filter-class>
- <init-param>
- <param-name>struts.devMode</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- ...
- </web-app>
2.加入了通配符的支持,這是在ww2中沒有的,如下:
- <action name="*" >
/tutorial/{1}.jsp - < SPAN>action>
【編輯推薦】