inotgo.com

Download area
File name File size
lib.rar 9m
struts.rar 9m

Tool version compatibility problem
Struts2 Based on MVC of WEB Frame
stay Hello Struts In , Will show the most basic Struts Configuration of
The follow-up study is carried out on this basis

Must read : Framework based programs run successfully , For JAR Package version , The correctness of the configuration file has strict requirements , Anything goes wrong , Will cause the framework program to fail . If you are learning this framework for the first time , Be sure to follow the instructions of the tutorial strictly , Completely imitate the operation , Until you successfully see the running effect . After the first success , Confidence , Ideas will have a better cushion , Then according to their doubts , stay “ success ” Make the desired changes and adjustments to your code , This can greatly save learning time , increase of efficiency , Don't change it at once , Create obstacles to your learning
Correct

Step 1 : Run... First , See the effect , Learn again   
Step 2 : Imitation and troubleshooting   
Step 3 : stay eclipse Create in Web Dynamic project struts   
Step 4 : Import jar Bag   
Step 5 : newly build web.xml   
Step 6 : to configure struts.xml   
Step 7 : establish index.jsp   
Step 8 : Deployed in tomcat In , Restart test   
Step 9 : Train of thought diagram   
Step 10 : Runnable project   
Step 11 : practice   

Step 1 :

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

edit top fracture
Struts A lot of steps need to be done , Any step is missing , Did something wrong , Can fail , This will affect the confidence of learning , And mistakenly think that this tutorial is impassable .

So first download the runnable project in the upper right corner struts.rar, Unzip and import to eclipse In , Start Tomcat, Observe for normal operation . Make sure you can run , Make sure the tutorial can run , Learn the following .

Import to Eclipse For the method of and operation in, please refer to : Import dynamic Web Project to Eclipse In

After successful deployment , Test address , You should see the effect shown in the figure

http://127.0.0.1:8080/struts/index


notes : This is a dynamic project format , I won't support it independent Tomcat Mode deployment
 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
Step 3 :

stay eclipse Create in Web Dynamic project struts

edit top fracture
stay eclipse New item in struts, use dynamic web project The way . Students who are not familiar with this way , Please refer to use Dynamic Web Project Develop in a way J2EE application
 stay eclipse Create in Web Dynamic project struts
Download the... In the upper right corner lib.rar, Unzip and copy to WEB-INF/lib in
 Import jar Bag
stay WEB-INF New under directory web.xml
One... Is configured Filter, All requests are filtered to this Filter
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
<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> </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>

</web-app>
stay src catalogue Next create a struts.xml File
This is the simplest struts.xml to configure
The effect is when visiting index When the path , The server jumps to index.jsp
 to configure struts.xml
<?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> <package name="basicstruts" extends="struts-default"> <action name="index"> <result>index.jsp</result> </action> </package> </struts>
<?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>
  <package name="basicstruts" extends="struts-default">

  <action name="index">
    <result>index.jsp</result>
  </action>    

</package>

</struts>
stay web catalogue Create... Under index.jsp,
The content is very simple It's just a sentence

Hello Struts2 World
 establish index.jsp
Hello Struts2 World
Hello Struts2 World
Step 8 :

Deployed in tomcat In , Restart test

edit top fracture
Deployed in Tomcat In , Restart tomcat, Then visit the address , Observation effect

http://127.0.0.1:8080/struts/index


It is equivalent to realizing servlet of Server jump To index.jsp The function of
For deployment methods, please refer to Through Eclipse Start Tomcat-Run On Server
 Deployed in tomcat In , Restart test
1. All visits will be web.xml Configured in Struts of Filter Intercepted
2. After interception , Just enter struts Workflow of
3. The visit address is /index, According to struts According to struts.xml Configuration in , The server jumps to index.jsp
4. Show index.jsp The content of
 Train of thought diagram
In the upper right corner, there is the runnable Project Download corresponding to this knowledge point , I really can't do it myself , Just download and unzip it and compare it
Step 11 :

practice

edit top fracture   Wrong posture , get half the results with double the effort ! Click to see the correct posture for the exercise
Prepare one hello.jsp File

Through configuration struts.xml Implement the access path /hello Jump to hello.jsp


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


Q & A area    
2021-03-24 Access path struts No problem
Big melon cattle




http://localhost:8080/index; http://localhost:8080/hello; Access is the right result But In the text http://localhost:8080/struts/index; http://localhost:8080/struts/hello Then come out 404 ( See Figure ); Why is this , What's wrong ? I am idea I made
 Loading
 
               
 
               


3 One answer

byxdbyj Jade
Answer time :2021-07-17
Has the landlord's problem been solved ? I have the same problem ..

Hard training technique
Answer time :2021-04-08
I solved it , Can be in IDEA In , By creating a new dynamic web project , To solve this problem . Do not import webmaster's project , Instead, create a new . You can refer to this article : https://blog.csdn.net/Awt_FuDongLai/article/details/115523552

Hard training technique
Answer time :2021-04-08
My situation is to visit http://localhost:8080/struts/index Will report 404 error , visit http://localhost:8080/struts/index.jsp The right page will appear . Does anyone know what's going on



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





2021-02-19 For exercises, you cannot access /hello The problem is
wsy_237000576




I'd like to ask about the practice hello How do you do it? , I think my struts.xml There is something wrong with the file ? Never access /hello,404 error
<?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>
  <package name="basicstruts" extends="struts-default">
 
  <action name="index">
    <result>index.jsp</result>
  </action>   
  <action name="hello">
  	<result>hello.jsp</result>
  </action>
 
</package>
 
</struts>
 
               





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





2020-11-29 There is a problem with the filter
2020-04-08 filter Configuration error
2020-02-17 web.xml Jump struts.xml


Too many questions , Page rendering is too slow , To speed up rendering , Only a few questions are displayed on this page at most . also 34 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-Hello Struts 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