Everything starts from the simplest, but what is difficult is how deep it can be.
I have three years of work experience and do not need struts. I have always been familiar with jsf, spring mvc, and struts2. When I start blogging, I want to record what I am interested in. I have observed my changes over the past three years, but I have never thought too much. How long can I stick to it as to how much it can change me, wait and see. I once saw struts2 three years ago and thought about me very young. without the guidance of a famous teacher, I was confused. After three years, I looked at him again, and I felt a lot of trouble in controlling these ponies. People grow up unconsciously.
Hello World of Struts2
Development Environment
1. STS 2.9.1
2. Maven 3.0
3. Tomcat 7.0
Maven POM
Create a maven-archetype-quickstart project in STS.
The configuration of struts2 is very simple. Add this in maven depnedency.
org.apache.struts struts2-core 2.3.15
Maven lib is like this after the successful deployment.
Please input your username
JSP
Test it with basic jsp
Add taglib of struts2
<% @ Taglib prefix = "s" uri = "/struts-tags" %>
Logon. jsp
please input your username
Welcom. jsp
mxiao sample of struts 2
Action
Write a HelloAction to record the user's name and return success.
.username = "SUCCESS"
Struts. xml
This is the struts configuration file, as shown in. It can identify the action and view used by the user's request pair. The following is the simplest example. This file should be stored in classpath at the end, so it should be placed in resources.
The above is the process for creating a basic struts program. The project structure is as follows:
Access URL
Http: /localhost: 9084/Struts2Example/User/Login. action