不错的struts插件:Struts Spring Plugin

http://struts.sourceforge.net/struts-spring/
不错的struts插件,可以让你用spring的Ioc容器来管理你的Action,以及为action注入需要的对象。
配置使用也比较简单。目前新的版本spring已经集成了这个插件,不用下载安装就可以使用。spring的apidoc里还有相关的说明。

   在struts-config.xml中加入插件的配置:
 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
        <set-property property="contextConfigLocation"
            value="/WEB-INF/applicationContext.xml"/>
    </plug-in>

在struts-config.xml中配置你的action的type为统一的代理
    <action path="/logon"
               type="org.springframework.web.struts.DelegatingActionProxy">
      <forward name="success"              path="/logon.jsp"/>
    </action>

在applicationContext.xml文件中,配置bean和你的action,注意配置action是,action的名字必须使用name属性指定。而普通的bean也可以用id指定。

<bean id="userDatabase" class="org.apache.struts.webapp.example.memory.MemoryUserDatabase" destroy-method="close" />
   
    <bean name="/logon" class="org.apache.struts.webapp.example.LogonAction">
      <property name="userDatabase"><ref bean="userDatabase" /></property>
    </bean>
看这样你的action实例将由spring的容器来生成,所以就可以完成userDatabase对象的注入了。
这里你不要试图配置用动态代理实现action的方法的拦截,那可能会有问题的,这可能有动态代理实现机制决定的。在这个连接的网站上有一个专门的struts插件可以实现action方法的拦截。
http://struts.sourceforge.net/saif/index.html

<script type="text/javascript"> <!-- google_ad_client = "pub-9232855773311077"; google_alternate_color = "99CC99"; google_ad_width = 250; google_ad_height = 250; google_ad_format = "250x250_as"; google_ad_channel =""; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-9232855773311077&dt=1110448669859&alt_color=99CC99&format=250x250_as&output=html&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=14&u_java=true" frameborder="0" width="250" scrolling="no" height="250" allowtransparency="65535">
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值