No configuration found for the specified action solution

Source: Internet
Author: User

http://blog.csdn.net/carefree31441/article/details/4857546

Using Struts2, configuring everything is OK, using common tag is OK, but when using <s:form> tag, the console always outputs a warning message.

The warning message reads as follows:

Warning:NoConfigurationFoundForTheSpecifiedAction: ' ShowMessage ' in namespace: '. FormAction defaulting to 'Action ' attribute ' s literal value.
2008-9-6 11:35:47 Org.apache.Struts2.components.Form Evaluateextraparamsservletrequest
Warning:NoConfigurationFoundForTheSpecifiedAction: ' ShowMessage ' in namespace: '. FormAction defaulting to 'Action ' attribute ' s literal value.

The showmsg.jsp code is as follows

<%@ taglib prefix= "s" uri= "/struts-tags"%>
......
<div>
Hello World
<s:form name= "ShowMessage" method= "POST"Action= "/hello/showmessage.Action ">
<s:textfield label= "User name" Name= "username" ></s:textfield>
<s:submit></s:submit>
</s:form>
</div>
......

The Struts.xml configuration is as follows:
......
<struts>
<package name= "Hello" extends= "Struts-default" namespace= "/hello" >
<Action name= "ShowMessage" class= "Com.historycreator.strutstest.ShowMessage" >
<result>/digg/showmsg.jsp</result>
</Action>
</package>
</struts>

The above exception occurs when you open the Showmsg.jsp page. Various configuration and access methods have been attempted, and warnings are presented. The answer to the search network almost always says to put <s:form name= "ShowMessage" method= "POST"Action= "/hello/showmessage.Action "in the >.The action is removed and the test is done, and the problem is still unresolved. More people let the <s: remove, do not tag, direct write <form> This of course there is no problem, but one will be marked, one will not use, very messy, and is not the fundamental way to solve the problem.

Workaround:
After testing found that is not the correct use of tag reason, in this case, the correct wording should be, <s:form name= "ShowMessage" method= "POST"action= "ShowMessage" namespace= "/hello" >


Cause Analysis:

Because the beginning of the use ofThe Struts2 label (form) does not specify the namespace property. SoSTRUTS2 will default from the root namespace "/" SearchAction '/hello/showmessage.action ', if the search does not go to the default namespace ' search action string, in the default namespace is definitely not found in its own definition action, so struts2 throws a warning message. &NBSP

Now that we have specified namespace as/hello, struts2 will be found directly in the/hello namespace. As you can imagine, if the requested action is not found in such a namespace, a similar message is thrown.  

Note, <s:form name= "ShowMessage" method= "POST"  action= "ShowMessage" Namespace= "/hello" >&NBSP;
cannot be written <s:form name= "ShowMessage" method= "POST"  action "namespace="/hello "> ",

There is still a corresponding warning message, and there is no access to the result after submission. Because there is no showmessage. action such a action, this. STRUTS2 will do the work for you automatically, and manually added is not possible, you do not have to superfluous. But on other occasions, such as using hyperlinks, you can add this. action.

No configuration found for the specified action workaround

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.