STEP1, create a new MAVEN project next step, select Maven-archetype-webapp
Next:
It was supposed to be a SSM .... Finish finished. Now the directory structure is like this
Next: Add source Folder:src/main/java, Src/test/java, src/test/resources
Right-click Engineering, build path, configure build path, and modify the output path of the source file
Then configure Project Facets
Click "Convert to Faceted" from ...
OK, start the project, enter http://localhost:8080/S2SS-demo/in the browser
STEP2: Adding the MAVEN framework first adds the MAVEN-dependent jar pack to the Pom.xml file. <!--add struts dependencies--> <dependency> <groupId>org.apache.struts</groupId> ;artifactid>struts2-core</artifactid> <version>2.3.15.1</version> </dependency> Then add the Struts.xml file under the Resource folder.
Then add struts configuration to the Web.xml file
Feel no problem, also configured in the Web.xml welcome-file=index.jsp, but access http://localhost:8080/S2SS-demo/will be an exception, There is no Action mapped for namespace [/] and action name [] associated with the context path [/s2ss-demo], http://localhost:8080/S2SS-demo/index.jsp can be normal Visit, should be by struts intercept, did not find the broken method. Useraction defines two methods, Login_input & login. In the Struts2 action, name can use wildcard characters. For example <action name= "*user" class= "com.s2ss.demo.UserAction" method= "{1}", You can match any action method in the user-terminated class com.s2ss.demo.UserAction.
Index.jsp page is like this
step3: Adding the Spring framework and struts thinking almost .... 1, first add spring-dependent dependencies in the Pom.xml file. <!--add Spring dependencies--> <dependency> <groupId>org.springframework</groupId> & nbsp <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid > <artifactId>spring-context</artifactId> <version>${spring.version}</ version> </dependency> <dependency> <groupId>org.springframework< /groupid> <artifactId>spring-web</artifactId> <version>${spring.version}</ Version> </dependency>
Add a plugin using spring in struts <dependency> <groupId>org.apache.struts</groupId> <artifactId> Struts2-spring-plugin</artifactid> <version>${struts.version}</version> </dependency>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.