Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of integrating Struts with Spring

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What is the method of Spring integrating Struts? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

The following shows how to implement spring integration with struts.

1. The application server does not directly call the method to start Spring, but the application server compiles and runs servlet,filter,listener, so spring provides a listener class that calls the methods in this class when the server initializes, so the configuration in the container is as follows:

< !-- 指定spring的配置文件,多个文件之间用逗号分隔 -->

< context-param>

< param-name>

ContextConfigLocation

< /param-name>

< param-value>

Classpath:beans.xml

< /param-value>

< /context-param>

< !-- 启动Spring容器 -->

< listener>

< listener-class>

Org.springframework.web.context.ContextLoaderListener

< /listener-class>

< /listener>

2. We configure the classes that we need to hand over to spring management in beans.xml:

Such as

< bean name="/user/regist" class="cn.sun.ssh.web.action.UserManagerAction">

< property name="dao" ref="userDAO">

< /property>

< /bean>

But action is called by the engine, how do we give the required action to the engine? by rewriting the processactioncreate method in the requestprocessor class in struts, we get the action in spring and give it to the engine management, which is also an extension mechanism of struts.

So we need to configure controller in struts-config.xml

< controller>

< set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>

< /controller>

In this way, Spring integration Struts is implemented.

This is the answer to the question about Spring's method of integrating Struts. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report