inotgo.com

Download area
File name File size
struts_spring.rar 16m

Tool version compatibility problem
Integrate Struts and Spring The basic idea is to Action The life cycle consists of the original Struts Manage , Leave it to Spring Manage

It's equivalent to that Li Sisi had to pick up guests by himself before , Now it's changed to the procuress to solicit , I'll give it back to Mr. Li for specific business Fuck Do

With struts Module iterator label Based on , Integrate
Correct


6 branch 26 second
This video uses html5 Play mode , If it cannot be played normally , Please upgrade your browser to the latest version , Recommend Firefox ,chrome,360 browser . If thunderbolt is installed , Play the video and show the direct download status , Please adjust Thunderbolt system settings - Basic settings - Start - Monitor all browsers ( Remove this option ). chrome of Video download Plug-in will affect playback , as IDM etc. , Please close or switch other browsers

Step 1 : Run... First , See the effect , Learn again   
Step 2 : Imitation and troubleshooting   
Step 3 : struts.xml   
Step 4 : applicationContext.xml   
Step 5 : to configure web.xml   
Step 6 : struts2-spring-plugin-2.2.3.1.jar   
Step 7 : Test   

Step 1 :

Run... First , See the effect , Learn again

edit top fracture
The old rule , First download the runnable project in the upper right corner , Configure to run , After confirming availability , Then learn what steps have been taken to achieve this effect .

Test address

http://127.0.0.1:8080/struts_spring/listProduct
 Run... First , See the effect , Learn again
Step 2 :

Imitation and troubleshooting

edit top fracture
After ensuring that the runnable project can run correctly , Then strictly follow the steps in the tutorial , Imitate the code again .
The imitation process inevitably has code differences , As a result, the expected operation results cannot be obtained , At this moment, by comparison The correct answer ( Runnable project ) And your own code , To locate the problem .
In this way , Learning is effective , Troubleshooting is efficient , It can obviously improve the learning speed , Across all the barriers on the way to learning .

It is recommended to use diffmerge Software , Compare folders . Put your own project folder , Compare with my runnable project folder .
This software is awesome , You can know which two files in the folder are wrong , And clearly marked
Here is a green installation and use tutorial : diffmerge Download and use tutorials
stay struts.xml Specify objectFactory The object factory is spring
That is action The creation of is left to spring conduct
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.i18n.encoding" value="UTF-8"></constant> <constant name="struts.objectFactory" value="spring"/> <package name="basicstruts" extends="struts-default"> <action name="showProduct" class="productActionBean" method="show"> <result name="show">show.jsp</result> </action> <action name="addProduct" class="productActionBean" method="add"> <result name="show">show.jsp</result> </action> <action name="listProduct" class="productActionBean" method="list"> <result name="list">list.jsp</result> </action> </package> </struts>
stay WEB-INF Under the directory , Create file applicationContext.xml
to configure productActionBean
notes : Don't put it in src below , Be sure to put it in WEB-INF Under the directory
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean name="productActionBean" class="com.how2java.action.ProductAction"> </bean> </beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
   http://www.springframework.org/schema/beans 
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/aop 
   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
   http://www.springframework.org/schema/tx 
   http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
   http://www.springframework.org/schema/context      
   http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
    <bean name="productActionBean" class="com.how2java.action.ProductAction">

    </bean>
</beans>
appoint Context monitor , The listener is tomcat When it starts, it will execute , For scanning WEB-INF/lib Whether there is... In the directory struts2-spring-plugin-2.2.3.1.jar
<web-app> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <dispatcher>FORWARD</dispatcher> <dispatcher>REQUEST</dispatcher> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app>
<web-app>
	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>
			org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
		</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<dispatcher>FORWARD</dispatcher>
		<dispatcher>REQUEST</dispatcher>		
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<listener>
  		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 	</listener>
 	
</web-app>
Step 6 :

struts2-spring-plugin-2.2.3.1.jar

edit top fracture
For consolidation struts and spring Plug in for jar
This is included in the complete project download of this example jar
At this point struts Used ProductAction Has been made by spring Created


http://127.0.0.1:8080/struts_spring/listProduct
 Test


The official account of programming , Follow and get the latest tutorials and promotions in real time , thank you .


Q & A area    
2020-02-19 Reception problem
nicococococ

This passage The meaning is too messy . It's better to say so Wu Sangui :request Procuress :struts Turtle :spring Li Sisi : program 1 Li Zicheng : program 2 Wu Sangui Find Procuress Find Li Sisi Wu Sangui Find Old steamed stuffed bun Find Turtle Turtle Let Li Zicheng go first (aop) Li Sisi received guests with a fine page in his mouth Turtle male plays the role of deployment




1 One answer

forestfire
Answer time :2021-01-15
You are a real cow bo, You can even say such coquettish words with fucking fine pages in your mouth



The answer has been submitted successfully , Auditing . Please My answer Check the answer record at , thank you
answer Or code please Fill in at least one , If you have a problem , Please ask again , Otherwise, the webmaster may not see




2019-12-01 Why do I run the teacher's project also prompt java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
sparksun007

The teacher's project has this hint, but it's no problem to run , My own project also has this hint , But I can't run , Excuse me, why ? My data source is using Hibernate Get from database , Now we can only struts and Spring Integrate , Then integrate Hibernate Other plug-ins are needed, aren't they ?




1 One answer

hz52
Answer time :2020-05-09
Spring What you need jar Did you pour all the bags in



The answer has been submitted successfully , Auditing . Please My answer Check the answer record at , thank you
answer Or code please Fill in at least one , If you have a problem , Please ask again , Otherwise, the webmaster may not see




2019-08-28 Ask the webmaster for help ,Struts+Spring The data encapsulated in the object still exists after resetting
2019-04-21 Solve this and say I didn't add method , But there is clearly
2019-04-05 Example names vary


Too many questions , Page rendering is too slow , To speed up rendering , Only a few questions are displayed on this page at most . also 5 Previous questions , please Click to view

Please... Before asking questions land
The question has been submitted successfully , Auditing . Please My question Check the question record at , thank you
about JAVA Frame -Struts+Spring- Integration steps Your questions

Try to provide Screenshot code and Abnormal information , Help to analyze and solve problems . You can also enter this station QQ Group communication : 496725845
Ask questions and try to provide complete code , Environment description , The more conducive to the recurrence of the problem , The faster your question can be answered .
Have questions about the code in the tutorial , Please provide which step , Which line is in doubt , This makes it easy to quickly locate the problem , Improve the speed at which questions are answered
In the thousands of questions that already exist , A considerable proportion , Because of the use of and webmaster Different versions of the development environment Resulting in , For example jdk, eclpise, idea, mysql,tomcat Wait, the version of the software is inconsistent .
Please use the same version as the webmaster , You can save yourself a lot of learning time . The webmaster sorted out the software versions used in teaching , It's all here , Convenient for everyone to download : /k/helloworld/helloworld-version/1718.html

Upload screenshot