webwork框架
webwork框架已經(jīng)整合到struts2中,struts2的工作方式就是由它改進(jìn)而來(lái)的。
struts2的基本流程
大致上,struts2框架由3部分組成:核心控制器FilterDispatcher、業(yè)務(wù)控制器和用戶實(shí)現(xiàn)的業(yè)務(wù)邏輯組件
核心控制器FilterDispatcher
負(fù)責(zé)攔截所有的用戶請(qǐng)求
業(yè)務(wù)控制器
即用戶實(shí)現(xiàn)的Action實(shí)例,負(fù)責(zé)控制流程走向
模型組件
負(fù)責(zé)業(yè)務(wù)邏輯的實(shí)現(xiàn)
視圖組件
struts2允許使用其它模板技術(shù),如FreeMarker、velocity。<result >的type屬性默認(rèn)為jsp
struts2的基本配置
配置web.xml
<filter>
<!—可以配置初始化參數(shù),常用的有cofig:指定配置文件位置,多個(gè)文件用逗號(hào)隔開(kāi)。也可以配置struts2常量,代替struts.properties文件-->
</filter>
<!—servlet 2.3以前的規(guī)范要手動(dòng)加載標(biāo)簽文件-->
<taglib>
</taglib>
配置struts.xml
<!—配置struts常量-->
<constant name="struts.i18n.encoding" value="GBK"/>
<!—配置bean,以利用控制反轉(zhuǎn)機(jī)制,定義的bean可以在xml其它直接引用-->
<bean type=? class=?>
<!—Action按模塊配置在多個(gè)文件中,使用這種方式合并-->
<include file=”struts-part1.xml”/>
<package name="lee" extends="struts-default">