<!--Ssh 加载applicationContext.xml 的几种方式
1. 在web.xml 里面配置一个监听器-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--2. 在web.xml 里面配置一个servlet-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!--3. 在struts-config.xml 文件里面配置一个插件来加载applicationContext.xml-->
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in>
<!--在配置struts <Action></Action> 时把他的type 类型=”org.springframework.web.struts.DelegatingActionProxy”
但他的 path=”/reg” 还是保持原来不变, Action类通过spring的DelegatingActionProxy 去创建,去管理.-->
<action-mappings>
<!-- type="com.dd.struts.action.RegAction" -->
<action attribute="regForm" input="/reg.jsp" name="regForm"
parameter="param" path="/reg" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy" />
</action-mappings>
<!--那spring 是怎么去创建和管理RegAction 类的实例呢?
在spring 的配置文件applicationContext.xml 里配置如下:-->
<bean name="/reg" class="com.dd.struts.action.RegAction">
<property name="dao" ref="dao"></property>
</bean>
<!--
<bean name=”/reg”> 是name 属性而不是id .名称一定要和struts-config.xml 里的对应的path=”/reg” 一样.
问题;
1.如果使用spring 来对Action创建.那struts 里面的RequestProcessor 还会不会执行?
2.如果我不想修改type=”com.dd.struts.action.RegAction” 那怎么办呢?
DelegatingRequestProcessor 继承struts 的RequestProcessor 我们可以写一个类来继承
DelegatingRequestProcessor 然后再重写他里面的
processPreProcess
processContent 方法实现字符过滤
只需要在struts-config.xml里面配置这样的一个请求处理类-->
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
ssh 框架的配制
最新推荐文章于 2019-03-31 11:06:00 发布