SpringとStrutsの統合
3757 ワード
Spring Struts
1. spring ActionSupport Struts
Struts action, struts action Spring ActionSupport, action getBean() Spring WebApplicationContext , 。 struts Action Spring 。
(1). applicationContext.xml
、 struts-config.xml
<plug-in className="org.springframework.web.struts.ContextLoaderPlugin">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml">
</set-property>
</plug-in>
、 web.xml
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <servlet> <servlet-name>context</servlet-name> <servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet>
(2). Action Action, Spring ActionSupport , applicationContext.xml getBean()
ApplicationContext context = this.getWebApplicationContext();
= context.getBean("idName");
new , , spring plicationContext.xml
2. spring Action Struts
Spring Action , Struts Action, Struts Action 。 Spring StrutsAction, Action ,
(1). applicationContext.xml
、 struts-config.xml
<plug-in className="org.springframework.web.struts.ContextLoaderPlugin">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml">
</set-property>
</plug-in>
、 web.xml
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <servlet> <servlet-name>context</servlet-name> <servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet>
(2) Action setXXX() , spring 。
(3) struts-config.xml <action> type 。
type="org.springframework.web.struts.DelegatingActionProxy"
(4). applicationContext.xml
3. , , !!!
(*^__^*) ……
Struts struts
Struts Action , Struts <action> type Struts Action , Spring StrutsAction 。
controller, struts-config.xml controller org.springframework.web.struts.DelegatingTilesRequestProcessor Struts Tiles , org.springframework.web.struts.DelegatingTilesRequestProcessor controller。 Struts Tiles , org.springframework.web.struts.DelegatingRequestProcessor controller。
:
(1). WebApplicationContext. 。
(2). EncodingProcessor DelegatingRequestProcessor process() process() :
request.setCharacterEncoding(UTF-8);
response.setContentType("text/html;charset=UTF-8");
(3). struts-config.xml , Struts RequestProcessor
controller Struts-config.xml <controller> ,
<controller processorClass="EncodingProcessor "/>
: 3 , Struts Spring , ;