Post-Struts Experience summary

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.