首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Struts1.调整Spring的三种方法

2012-10-13 
Struts1.整合Spring的三种方法关键字: struts1 ????? typeorg.apache.struts.validator.DynaValidatorFo

Struts1.整合Spring的三种方法

关键字: struts1

????? type="org.apache.struts.validator.DynaValidatorForm">
?????????????? < form-property name="isbn"??? type="java.lang.String"/>
??? < /form-bean>
?
? < /form-beans>

?< action??? path="/searchSubmit"
?????????????? type="com.iwtxokhtd.books.actions.SearchSubmit"
?????????????? input="/searchEntry.do"
?????????????? validate="true"
?????????????? name="searchForm">
????????????? < forward name="success" path="/WEB-INF/jsp/detail.jsp"/>
????????????? < forward name="failure" path="/WEB-INF/jsp/search.jsp"/>
??? < /action>?

?< controller processorvalue="/WEB-INF/classes/applicationContext.xml"/>
?< /plug-in>

然后在spring配置文件applicationContext.xml文件中进行bean配置:

< beans>
? < bean id="bookService" //一定要与struts-config.xml文件中的action中的path名一样
???
???????????? type="org.springframework.web.struts.DelegatingActionProxy"

???????????? input="/searchEntry.do"
???????????? validate="true"
???????????? name="searchForm">
???????????? < forward name="success" path="/WEB-INF/pages/detail.jsp"/>

???????????? < forward name="failure" path="/WEB-INF/pages/search.jsp"/>
??? < /action>?

< plug-in
??? className="org.springframework.web.struts.ContextLoaderPlugIn">
??? < set-property property="contextConfigLocation" value="/WEB-INF/classes/application.xml"/>
?< /plug-in>

然后在applicatinContext.xml文件中配置:

< beans>
? < bean id="bookService" class="ca.nexcel.books.business.BookServiceImpl"/>

? < bean name="/searchSubmit"??
??????? class="com.iwtxokhtd.books.actions.SearchSubmit">
???? < property name="bookService">//dao
??????? < ref bean="bookService"/>//dao impl
???? < /property>
? < /bean>

< /beans>

此方法是三种方法中最好的

热点排行