好久沒寫了,過了個年,過了七天豬的日子,吃了睡睡了吃中間偶爾看看電視,為假期準備了幾個電影都沒看,唉:-(忙,上了幾天班了,怎么感覺這周過的這么慢呢,剛剛剛周四
昨兒看了一集struts2
總結幾點
1、struts.xml中的package標簽有個abstract="true"屬性,如果為true,則這個package中不能有<action>標簽,為true表示這個package為一個抽象package,就像java中的接口中不能有方法實現似的。
2、package標簽還有個namespace屬性,它關系到這個package中的action訪問路徑,默認是"",比如
<package name= "capinfo" extends= "struts-default" namespace="/hello">
<action name= "HelloWorld"
class= "com.capinfo.struts2.action.HelloWordAction" >
<result>/HelloWorld.jsp</result>
</action>
</package>
則jsp中則應為<form action="/hello/HelloWorld.action" method="post">,如果沒有找到hello/HelloWorld.action則會尋找namespace為""的,也就是HelloWorld.action,如果再沒有,就會拋出異常。
3、在struts1中可以有多個struts-config.xml的文件,只要在web.xml配置org.apache.struts.action.ActionServlet時加到config參數中,以逗號分隔,在struts2中也可以有多個struts.xml形式的文件,這次不需要修改web.xml了,在struts.xml中添加諸如
<include file=""/>就Ok了
4、關于struts各種參數的配置信息位于struts2-core.jar/org.apache.struts2/default.properties中,如果要修改里面的配置,有兩種方式,一是在struts.xml中配置,例如<constant name="struts.devMode" value="true" />,二是在classess中建一個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)
###
就總結這么些先。