Spring 整合Struts的三个小窍门(三)
来源:互联网 发布:浙工大网络教学平台 编辑:程序博客网 时间:2024/05/02 17:16
窍门 3. 将动作管理委托给 Spring
步骤:
1. Action 中,使用IOC 获得服务,配置struts-config.xml:
<!-- 一个Action 注意其type Spring 代理类 -->
<action path="/searchSubmit"
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>
2. Spring 配置文件中注册该动作:
<bean id="bookService"
class="ca.nexcel.books.business.BookServiceImpl" />
<bean name="/searchSubmit"
class="ca.nexcel.books.actions.SearchSubmit">
<property name="bookService">
<ref bean="bookService" />
</property>
</bean>
优点
1. 动作委托解决方法是这三种方法中最好的。
2. 不使用Spring api 编写 Action
3. 利用了IOC 装配
步骤:
1. Action 中,使用IOC 获得服务,配置struts-config.xml:
<!-- 一个Action 注意其type Spring 代理类 -->
<action path="/searchSubmit"
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>
2. Spring 配置文件中注册该动作:
<bean id="bookService"
class="ca.nexcel.books.business.BookServiceImpl" />
<bean name="/searchSubmit"
class="ca.nexcel.books.actions.SearchSubmit">
<property name="bookService">
<ref bean="bookService" />
</property>
</bean>
优点
1. 动作委托解决方法是这三种方法中最好的。
2. 不使用Spring api 编写 Action
3. 利用了IOC 装配
- Spring 整合Struts的三个小窍门(三)
- Spring 整合Struts的三个小窍门(一)
- Spring 整合Struts的三个小窍门(二)
- Struts 动作整合到 Spring 框架中的三种窍门
- Spring的小窍门
- 整合Struts,Spring,mybatis三个框架的helloworld
- Spring整合Struts的三种方法
- 关于struts与spring整合的一个小案例入门
- 有关Spring与struts整合的小问题
- spring和struts的整合的三种方式
- 背英语四级单词的三个小’窍门
- 用xdebug优化php的三个小窍门
- Spring 和struts 整合的三种方式
- Spring 和struts 整合的三种方式
- 三种整合 Struts 应用程序与 Spring 的方式
- Spring与struts 整合的三种方式
- Spring 和 struts 整合的三种方式
- 三种整合 Struts 应用程序与 Spring 的方式
- 输入一组整数后用c语言数据结构对其进行大小比较以二叉树存储、遍历
- 在安装sql2000会出现这个错误提示.
- Spring 整合Struts的三个小窍门(二)
- 更改源数据库DMP字符集以符合导入至目标字符集(oracle8--&gt;oracle9i)
- 微软提供的URL Rewrite与Intelligencia的UrlRewrite.Net
- Spring 整合Struts的三个小窍门(三)
- 一段JS
- 把公式存储为字符串
- 《十二个故事》
- ASCII码表
- 簡易的 Url Rewriting 隱藏 Querystring
- C# 装箱和拆箱转换
- Apache URL rewrite规则
- HP-UX一些命令