When the chain and redirectaction types (Type-result) are used in struts2.xml, a check error (validation) is reported)

Source: Internet
Author: User

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
-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>

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>

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:


<! -- Step 1: Configure namespace = "/" -->

<Package name = "globle" extends = "struts-Default" namespace = "/">

<! -- Custom result-type -->

<Result-type name = "alert" class = "com. PK. Web. Action. aertaction">


<! -- 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>

<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>


Test diagram

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.