What the hell is Struts2?
Citing the introduction of Baidu Encyclopedia:Struts2 is a Web application framework based on the MVC design pattern, essentially equivalent to a servlet, in the MVC design pattern, Struts2 as a controller to establish the data interaction between the model and the view. .
Introduction completed ...
Its core schematic diagram online a lot, I made a simple change here, if there is not enough to explain the place, please correct me. Schematic please look:
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/9C/F9/wKiom1l4U9yTE1zLAAKXjfqcBXE049.png-wh_500x0-wm_ 3-wmp_4-s_2912047666.png "title=" Ylt.png "alt=" Wkiom1l4u9yte1zlaakxjfqcbxe049.png-wh_50 "/>
All right, we're almost done here, let's talk about something useful. Struts2 How to use it, look at the following steps
1. Create a new Web project (as if it were nonsense)
2. Import the Struts2 jar package
3. Writing the Web. XML configuration
4. Writing Struts.xml Configuration
5. Write the Action class
6. Writing JSP pages
The first two steps are ignored, directly starting with the third step:
3. Introducing Struts2 in Web. XML (actually a filter)
<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> <url-pattern>/*</url-pattern> </ Filter-mapping>
4. Write the Struts.xml configuration (this file is placed in the SRC root directory)
<package name= "Default" namespace= "/" extends= "Struts-default" > <!--Specify method call--<action name= "use RLogin "class=" Com.pxy.action.Hello "><result>/login.jsp</result> </action></package>
5. Write the action class (put in the com.pxy.action package)
public class Hello extends Actionsupport {@Overridepublic String execute () throws Exception {System.out.println ("Default Call Method! "); return SUCCESS;}}
6. Writing JSP pages
<body> Login Interface <br/> <form action= "method=" POST "> Account: <input type=" text "name=" loginID "/>< br/> Password: <input type= "password" name= "loginpwd"/><br/> <input type= "Submit" value= "Login"/> </form> </body>
All the coding is done here, and then we enter the http://localhost:8080/strDemo/userLogin.action in the address bar to try the results. Normal access to the login.jsp page.
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/9C/F9/wKioL1l4V4aB__yiAAAex-mtWfc416.png-wh_500x0-wm_ 3-wmp_4-s_3753036503.png "title=" Jg.png "alt=" Wkiol1l4v4ab__yiaaaex-mtwfc416.png-wh_50 "/>
I modified the tomcat port to 8888.
Sir, you are satisfied.
If something goes wrong, it must be your posture is not right, get up and go to bed again.
If it is not right, then sleep a little more, wake up must be normal, please believe me ...
This article is from the "Software Thinking" blog, please be sure to keep this source http://softi.blog.51cto.com/13093971/1951172
Java from getting started to giving up: a basic way to access Struts2