[Html]
(1) Configure struts2 in eclipse
(2) copy the struts2-spring-plugin-2.0.11.2.jar package to the WEB-INF \ lib directory
(3) Configure spring in web. xml
<Listener>
<Listener-class> org. springframework. web. context. ContextLoaderListener </listener-class>
</Listener>
Remember, if you have used spring before, please remove the spring configuration.
<Servlet>
<Servlet-name> context </servlet-name>
<Servlet-class>
Org. springframework. web. context. ContextLoaderServlet
</Servlet-class>
<Load-on-startup> 1 </load-on-startup>
</Servlet>
(4) Modify applicationContext. xml
<Beans default-autowire = "byName" xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
(5) add in struts. xml
<Constant name = "struts. objectFactory" value = "spring"/>
(6) define action in the spring configuration file applicationContext. xml
<Bean id = "SearchBusLineAction"
Class = "com. bus. struts2.action. SearchBusLineAction" abstract = "false"
Lazy-init = "default" autowire = "default" dependency-check = "default">
<Property name = "busService">
<Ref bean = "BusServiceImpl"/>
</Property>
</Bean>
(7) define action in struts. xml
<! -- Note that class = "SearchBusLineAction" instead of com. bus. struts2.action. SearchBusLineAction is defined in applicationContext. xml of spring. -->
<Action name = "searchBusLine" class = "SearchBusLineAction">
<Result name = "success" type = "freemarker">/index. jsp </result>
</Action>
(1) Configure struts2 in eclipse
(2) copy the struts2-spring-plugin-2.0.11.2.jar package to the WEB-INF \ lib directory
(3) Configure spring in web. xml
<Listener>
<Listener-class> org. springframework. web. context. ContextLoaderListener </listener-class>
</Listener>
Remember, if you have used spring before, please remove the spring configuration.
<Servlet>
<Servlet-name> context </servlet-name>
<Servlet-class>
Org. springframework. web. context. ContextLoaderServlet
</Servlet-class>
<Load-on-startup> 1 </load-on-startup>
</Servlet>
(4) Modify applicationContext. xml
<Beans default-autowire = "byName" xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
(5) add in struts. xml
<Constant name = "struts. objectFactory" value = "spring"/>
(6) define action in the spring configuration file applicationContext. xml
<Bean id = "SearchBusLineAction"
Class = "com. bus. struts2.action. SearchBusLineAction" abstract = "false"
Lazy-init = "default" autowire = "default" dependency-check = "default">
<Property name = "busService">
<Ref bean = "BusServiceImpl"/>
</Property>
</Bean>
(7) define action in struts. xml
<! -- Note that class = "SearchBusLineAction" instead of com. bus. struts2.action. SearchBusLineAction is defined in applicationContext. xml of spring. -->
<Action name = "searchBusLine" class = "SearchBusLineAction">
<Result name = "success" type = "freemarker">/index. jsp </result>
</Action>
Author: Tender001