struts2和spring整合比较深入的分析(在struts.xml中指定ClassName与指定BeanID的区别)...

本文探讨了在Struts2框架中如何通过配置文件struts.xml整合Spring框架,重点介绍了在定义Action时使用类名与Bean ID的区别。通过具体示例说明了不同配置方式下Action的处理过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

struts.xml
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"


    "http://struts.apache.org/dtds/struts-2.0.dtd"

>
<struts>


    <include file="struts-default.xml"

/>



    <package name="default"

 extends="struts-default"

>


        <action name="foo"

 class="com.acme.Foo"

>


            <result>

foo.ftl</result>


        </action>


    </package>



    <package name="secure"

 namespace="/secure"

 extends="default"

>


        <action name="bar"

 class="bar"

>


            <result>

bar.ftl</result>


        </action>


    </package>


</struts>

Where you have a Spring bean defined in your applicationContext.xml named "bar". Note that the com.acme.Foo Action did not need to be changed, because it can be autowired.

 

如何理解这句话,本文附件告诉你答案:  关于Struts2与Spring整合的一些疑惑及解释。  文中主要谈在struts.xml中配置Action的时候,在class属性上指定className与指定BeanID的区别。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值