This article is not original, this article is copied to http://blog.sina.com.cn/s/blog_850822020100u5ct.html
The myeclipse method is 9.0m1
When the chain and redirectaction types are used in struts. XML, a check error is returned!
Multiple annotations found at this line:
-Undefined actionnamespace
Parameter
-Undefined actionname Parameter
I believe that many of my friends will suffer from this mistake. Now I am going to talk about the solution. I have searched Baidu and Google for a long time. I have also read some foreign websites and haven't found a solution for half a day, later, I accidentally saw the struts2chain instructions on the Apache website. After reading the instructions carefully, I thought of a solution that could solve the problem. So I tested it, the problem is completely solved. Now let's talk about the next solution.
The chain result type has four attributes:
Actionname (default)-the name of the action that will be chainedto
Namespace-used to determine which namespace the action is in thatwe're chaining. If namespace is null, This defaults to the currentnamespace
Method-used to specify another method on target action to beinvoked. If null, This defaults to execute Method
Skipactions-(optional) the list of comma separated action namesfor the actions that cocould be chained
The actionname and namespace are essential. Otherwise, an error is returned. So I wrote the following form in the project:
<Package name = "struts" extends = "struts-Default" namespace = "/BG">
<Action name = "login" class = "loginaction">
<Result type = "chain">
<Paramname = "actionname"> index </param>
<Paramname = "namespace">/BG </param>
</Result>
</Action>
</Package>
But there is a problem with this writing. My project is relatively simple and I don't want to use a namespace. So I want to solve this problem. When reading the official documentation, I found this sentence:
A root namespace ("/") is also supported. the root is the namespacewhen a request directly under the context path is already ed. as withother namespaces, it will fall back to the default ("") namespaceif a local action is not found.
So I thought, "/" instead of "/BG" would not solve the problem. Then write the code as follows:
<Package name = "struts" extends = "struts-Default" namespace = "/">
<Action name = "login" class = "loginaction">
<Result type = "chain">
<Paramname = "actionname"> index </param>
<Paramname = "namespace">/</param>
</Result>
</Action>
</Package>
Now, I think everyone understands how to solve the problem of checking errors (validation) in the results of chain and redirectaction!
Please kindly advise if there are many mistakes !!
This article is not original, this article is copied to http://blog.sina.com.cn/s/blog_850822020100u5ct.html
Bytes ----------------------------------------------------------------------------------------
The following is my test code:
<Struts>
<! -- Step 1: Configure namespace = "/" -->
<Package name = "globle" extends = "struts-Default" namespace = "/">
<! -- Custom result-type -->
<Result-types>
<Result-type name = "alert" class = "com. PK. Web. Action. aertaction">
</Result-type>
</Result-types>
<! -- Chains action -->
<Action name = "loginaction" class = "com. PK. Web. Action. loginaction1">
<Interceptor-ref name = "time"> </Interceptor-ref>
<Interceptor-ref name = "defaultstack"> </Interceptor-ref>
<Result>/success. jsp </result>
<Result name = "input" type = "chains">
<Param name = "actionname"> emailaction </param>
<Param name = "namespace">/</param>
</Result>
</Action>
<Action name = "emailaction" class = "com. PK. Web. Action. emailaction">
<Result name = "success" type = "alert">
<Param name = "location">/email. jsp </param>
<Param name = "message"> login successful </param>
</Result>
</Action>
</Package>
</Struts>
Test diagram