Struts2 DWR there is no action mapped for action... Cause and Solution

Source: Internet
Author: User

When configuring struts2, the configuration in Web. XML is as follows:

 1     <  Filter  >  2         <  Filter-name  > Struts2 </  Filter-name  >  3         <  Filter-class  > Org. Apache. struts2.dispatcher. Ng. Filter. strutsprepareandexecutefilter</  Filter-class  >  4     </  Filter  >  5     <  Filter-Mapping  >  6         <  Filter-name  > Struts2 </  Filter-name >  7         <  URL-Pattern  > /* </  URL-Pattern  >  8     </  Filter-Mapping  > 

The configuration of DWR in Web. XML is as follows:

 1     <  Servlet  > 2         <  Servlet-name  > DWR-invoker </  Servlet-name  >  3         <  Servlet-class  > Org. directwebremoting. servlet. dwrservlet </  Servlet-class  >  4         < Init-Param  >  5             <  Param-name  > Debug </  Param-name  >  6             <  Param-Value  > True </  Param-Value  > 7         </  Init-Param  >  8     </  Servlet  >  9     <  Servlet-Mapping  >  10         <  Servlet-name  > DWR-invoker </ Servlet-name  >  11         <  URL-Pattern  > /DWR /* </  URL-Pattern  >  12     </  Servlet-Mapping  > 

 

Struts2 uses/* as the URL-pattern. In the struts mechanism, as long as there is no suffix name in the Request Path or the suffix name is. Action, it is treated as an action. Therefore, after DWR is configured, The js method list exposed in the current system should be displayed after the class is clicked on the test page, display there is no action mapped for action... similar information is because after you click the class name link, the path does not have a suffix. There are two solutions:
(1) define in struts. properties:
Struts. Action. Extension = action

Because the default configuration of struts2 is:
Struts. Action. Extension = action (note that there is a comma next to it)

(2) set in struts. properties:
Struts. action. excludepattern =/DWR. *,/webeditor. * (Note: Here is a regular expression, not the URL matching mode. Therefore, write/DWR. * Instead of/DWR /*)
In this way, configure strutsprepareandexecutefilter. The filterdispatcher configuration is invalid.

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.