当前位置:编程学习 > JAVA >>

浅析如何让Spring 来管理Action的配置方法

在struts.xml中添加下面的句子,让spring来管理action

[html]
<struts> 
<constant name="struts.objectFactory" value="spring"/> 
</struts> 

下面看看applicationContext.xml中的action配置
[html]
<bean id="<span style="color:#ff6666;">registAction</span>"   
        class="org.arthur.lr.system.RegistAction">    
        <!-- 依赖注入DAO组件所必需的SessionFactory引用 -->    
        <property name="mgr" ref="umi">    
        </property>    
    </bean>   

然后看看怎么把这个在struts.xml中应用这个bean
[html] 
<!-- 其中class 中registAction指的是spring配置文件的一个id好为registAction的bean --> 
        <action name="<span style="color:#ff0000;">regist</span>" class="<span style="color:#ff6666;">registAction</span>" > 
                     <result>/success.jsp</result> 
                     <result name = "input">/regist.jsp</result> 
             <result name = "failure">/regist.jsp</result> 
        </action> 

如果要用ajax技术发送到某个action,其中url也写成配置文件中的action名字即可
比如$.post(“regist”, {json: name}, callBack, "json");


作者:chunqiuwei
补充:软件开发 , Java ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,