The namespace in struts2 indicates struts2namespace.

Source: Internet
Author: User

The namespace in struts2 indicates struts2namespace.

<Package name = "user"Namespace = "/user"Extends =" struts-default ">
<Action name = "logon" class = "cn.net. cipe. ots. user. actions. UserAction" method = "logon">
<Result name = "success">/JSP/main. jsp </result>
<Result name = "input">/JSP/login. jsp </result>
<Result name = "error">/JSP/login. jsp </result>
</Action>

</Package>

Note:

This user indicates that there must be a folder named user under WebRoot.

In jsp, there are three writing methods:

First

<Form action = "logon. action">

.....

</Form>

Second

<Form action = "/user/logon. action">

.....

</Form>

Third

<S: form action = "logon. action" namespace = "/user">

.....

</S: form>

The first method can be tested because FilterDispatcher searches for the action logon in the root directory and subdirectories of the package.

The second method is the formal method, which can be tested because FilterDispatcher splits the form jump into logon. action and nanespace =/user, and then directly hit the package whose namespace is "/user" under the package.

The third method is unfortunately unable to pass the test because s: the form tag does not add the namespace value to the form action attribute when generating the html page .....

This is the opposite of the third case. If you use s: url, you must write the namespace. See the following example:

<S: url href = "/user/logon. action"/> This method is prone to errors because html code is messy when namespace is not written.

<S: url href = "logon. action" namespace = "/user"/> correct syntax!

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.