namespace problems in Struts2

Source: Internet
Author: User

Recently, because of the need for a project walkthrough, we need to learn the Java EE system. Adopted is struts2, found that good, the first day to get struts2 on half a day, and finally found that it was not redeployed after the introduction of the package, directly restart the server caused the package was not introduced to the Webroot directory web-inf lib directory, Later, note that the introduction of the package requires not only restarting the server Tomcat, but also redeploying the project.

Today, I encountered a problem, in the learning Struts2 namespace has been error access, and now finally understand, the problems you have encountered summed up:

1. When configuring the Namespace property of the package section of the Struts.xml file, you must add "/", because today is not added to this, half a day is not found, you must start with a slash.

2. Default name space. If you do not have the namespace attribute when configuring the package section, it is using the default namespace, which in my understanding is that you can access your action directly, regardless of how many layers you have in front of your testaction, you can go through http:// Localhost:8080/webdemo/test.action Access (Webdemo is the site name). One interesting thing about this is that the URL to the content of the default namespace can be arbitrary, such as accessing the above test.action, you can add anything between Webdemo and test.action, such as: http://localhost:8080 /webdemo/abc/egeag/sagjiea/test.action. Because he's going to be in "/abc/egeag/sagjiea." The name space to look for test.action, if not found, he will be in all the default namespace of the package to look for, that is, he will be in all the namespace properties of the package, so no matter what you add to the limit, he will find ... It's amazing.

3. When you add a namespace, you need to add a qualified name to the namespace, and if the namespace attribute in package is "/test" then the access needs to write Http://localhost:8080/webdemo/test/test.action.

4. For the console to print out the information needs to check, today because there is no attention to error information, access to half-day access, and finally found that the error is not found Struts2-default parent package, Originally i in extends attribute write is Struts2-default not struts-default, careless extremely, just contact to make so much trouble.

5. My understanding is that namespaces are a way to resolve address conflicts, and you can resolve the conflict by namespace ways.

Personal notes, there are errors that wish to point out.

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.