1、首先在struts-config.xml中加入下面代码:
<struts-config>
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml" />
</plug-in>
</struts-config>

注:为 Struts 的 ActionServlet 装载 Spring 应用程序环境。就像添加任何其他插件一样,简单地向您的 struts-config.xml 文件添加该插件。
2、对Action进行配置
<action-mappings>
<action path="/login"
type="org.springframework.web.struts.DelegatingActionProxy"
name="loginForm">
<forward name="success" path="/main.jsp" />
<forward name="failure" path="/login.jsp" />
</action>
</action-mappings>

注:,Struts 在运行期加载的实际上是DelegatingActionProxy , 而
DelegatingActionProxy则实现了针对实际Action的调用代理,Struts最终调用的将是由Spring
管理的Action实例。
3、在beans.xml中配置的要点:
<bean name="/login" class="net.xiaxin.action.LoginAction"
singleton="false">
<property name="userDAO">
<ref bean="userDAOProxy" />
</property>
</bean>
注意这里的bean要定义成name,而不要定义成id

相关文章:

  • 2021-08-20
  • 2021-12-01
  • 2021-07-10
  • 2021-12-10
  • 2022-12-23
  • 2022-01-25
猜你喜欢
  • 2021-09-21
  • 2021-10-04
  • 2022-03-07
  • 2022-02-08
  • 2022-02-16
  • 2021-04-24
  • 2021-12-09
相关资源
相似解决方案