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!