struts 与 spring 整合

struts 与 spring 整合步骤:

一、添加struts开发环境  

  1,先单独添加struts架包,和struts.xml文件

  2,修改web.xml文件,把下列代码放进去,配置struts2的核心过滤器.

<filter>        
  <filter-name>struts2</filter-name>         
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>     
</filter>

<filter-mapping>         
    <filter-name>struts2</filter-name>         
    <url-pattern>/*</url-pattern>    
</filter-mapping>

  3,把struts.xml文件内容中配置开发模式,改为true

  4,写struts.xml中action配置的时候不能提示,

    解决提示的方法:

      1)拷贝struts.xml文件中的这些内容:http://struts.apache.org/dtds/struts-2.0.dtd

      2)在工具window选项中preferences窗口,搜索xml

      3)在xml Calalor 中选择add添加 key为:http://struts.apache.org/dtds/struts-2.0.dtd ,选择key type:为url ,再指定Location:为类库目录下的                                 src\core\main\resources的dtd文件

二、添加spring的开发环境

  1,先单独添加spring架包:先从\spring-framework-2.5.6.SEC01\lib\jakarta-commons加日志的包commons-logging.jar,和从\spring-framework-2.5.6.SEC01\lib\jakarta-commons\cglib加cglib-nodep-2.1_3.jar和做AOP用的两个包:\spring-framework-2.5.6.SEC01\lib\jakarta-commons\aspectj下的aspectjrt.jar和aspectjweaver.jar。

  2,拷贝:applicationContext.xml到工程中,确定是否有beans标签,并把内容删掉。

 

三、测试:

    

posted @ 2013-05-13 12:39  东泉  阅读(180)  评论(0)    收藏  举报