Perhaps some people feel that struts is not easy to learn, it seems that some of the concepts in the MVC1, MVC2, mode ... I write this article is to let the person who has never contacted struts, can have a simple introductory guide, of course, the systematic learning struts is necessary, there are a lot of people enchanted Dongdong, that is something.
The case includes homepage, user login, website wizard page. As simple as this, there is no esoteric concept of struts, mainly by hands-on, and then by heart.
WEB Server uses TOMCAT4. Download struts1.1 to http://jakarta.apache.org, release zip file to c:\struts, copy C:\struts\webapps\struts-example.war to c:\tomcat4\ In WebApps, the boot Tomcat,war package is released as the Struts-example folder, the war package is deleted, and the Struts-example folder is renamed to test.
First, change the web-inf\web.xml into:
! DOCTYPE Web-app Public "-//sun Microsystems, INC.//DTD Web Application 2.2//en" "Http://java.sun.com/j2ee/dtds/web-app_ 2_2.dtd ">
action
org.apache.struts.action.ActionServlet
config
/web-inf/struts-config.xml
1
!--The servlet of the system can be mapped to a file with a cool suffix, rather than a common. Jspdo and so on, suffix name can be changed to any name, of course the name to health # ¥%! -->
action
*.cool
!--The default home page for this system is index.jsp, you can have multiple, system in order, similar to iis-->
index.jsp
Two, change test\web-inf\ struts-config.xml to:
! DOCTYPE struts-config Public "-//apache Software foundation//dtd struts Configuration 1.1//en"
"http:// Jakarta.apache.org/struts/dtds/struts-config_1_1.dtd ">
!--Formbean is a concept of struts, The essence is JavaBean, used to automatically store the values of each field in the page form, and return to the form field at the appropriate time, do not need to be request.getparameter ("FieldName") as traditional; Using-->
"!--here is a global steering relay (Forward) address that can be used throughout the system, similar to the window.location in JavaScript (' index.jsp ' , and similar to the various buttons on the TV controller, the channel, color palette and so on is based on the Web application of struts flow control process. Typically, when an action is processed, it is forwarded to a JSP page for display. This is also the main point of the implementation of MVC in JSP. -->
!--Failed.cool will be used as a servlet request to find the corresponding action processing in action-mappings. -->
!--Remember the request for a cool suffix in web.xml? They are transferred here for processing. This is the same as the model section of struts, the model is more flexible in strutsPlace. -->
!-- Processing the regist.cools request, using the Formbean is UserForm, Test.userform class, and returns index.jsp-->