好久沒寫了,過了個(gè)年,過了七天豬的日子,吃了睡睡了吃中間偶爾看看電視,為假期準(zhǔn)備了幾個(gè)電影都沒看,唉:-(忙,上了幾天班了,怎么感覺這周過的這么慢呢,剛剛剛周四
昨兒看了一集struts2
總結(jié)幾點(diǎn)
1、struts.xml中的package標(biāo)簽有個(gè)abstract="true"屬性,如果為true,則這個(gè)package中不能有<action>標(biāo)簽,為true表示這個(gè)package為一個(gè)抽象package,就像java中的接口中不能有方法實(shí)現(xiàn)似的。
2、package標(biāo)簽還有個(gè)namespace屬性,它關(guān)系到這個(gè)package中的action訪問路徑,默認(rèn)是"",比如
<package name= "capinfo" extends= "struts-default" namespace="/hello">
<action name= "HelloWorld"
class= "com.capinfo.struts2.action.HelloWordAction" >
<result>/HelloWorld.jsp</result>
</action>
</package>
則jsp中則應(yīng)為<form action="/hello/HelloWorld.action" method="post">,如果沒有找到hello/HelloWorld.action則會(huì)尋找namespace為""的,也就是HelloWorld.action,如果再?zèng)]有,就會(huì)拋出異常。
3、在struts1中可以有多個(gè)struts-config.xml的文件,只要在web.xml配置org.apache.struts.action.ActionServlet時(shí)加到config參數(shù)中,以逗號(hào)分隔,在struts2中也可以有多個(gè)struts.xml形式的文件,這次不需要修改web.xml了,在struts.xml中添加諸如
<include file=""/>就Ok了
4、關(guān)于struts各種參數(shù)的配置信息位于struts2-core.jar/org.apache.struts2/default.properties中,如果要修改里面的配置,有兩種方式,一是在struts.xml中配置,例如<constant name="struts.devMode" value="true" />,二是在classess中建一個(gè)struts.properties,在里面配置比如struts.i18n.encoding=GBK,在struts2-core.jar/org.apache.struts2/default.properties中有一下這句注釋,說明了struts.properties將覆蓋default.properties中的配置
### Struts default properties
###(can be overridden by a struts.properties file in the root of the classpath)
###
就總結(jié)這么些先。