1.struts is mostly around "action", so long as it finds "action" it knows what to do. First configure the Struts.xml, we can see that the action name= "index", and result needs to return to an interface "index.jsp", the specific code is as follows:
<struts><Packageextends= "Struts-default" > <action name= "index" ><result >/index.jsp</result> </action> </Package ></struts>
2. Modify "index.jsp", only output a sentence: Hello struts2! specific code as follows:
<title> Home </title>Hello Struts2!</body>
3. Deploy the project, restart tomcat7.0 enter Http://localhost:8080/Struts1/index (or http://localhost:8080/Struts1/index.action) in the address bar and the results are as follows:
4. When we change the "name" of the "action", the other place is unchanged, corresponding to the address bar also changed its name, but there will be no previous results, error (Cannot find "action"). The specific code is as follows:
<struts><Packageextends= "Struts-default" > <action name= "Hello" > <result >/index.jsp</result> </action> </Package ></struts>
However, there is a warning, the workaround: This situation requires restarting the service and redeploying the project. Now there is a way to do this once and for all: Add constants to the Struts.xml file <constant name= "Struts.devmode" value= "true"/> so that it has been in development mode (IE development modes) ( It is important to note that the default value of value "false" is changed to "true" in order to be a development mode). Then you need to restart the service, run again, and succeed.
5. Summary:
Writing procedures can be used in a small way: the Address bar needs to enter the corresponding project name, but too long easy to write wrong, it is OK, right now click on the item directly select Copy qualified name, you can fill in the name of the project is accurate in the address bar.
Post-Struts Experience summary