`
javasunnyboy
  • 浏览: 75047 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

解决:No configuration found for the specified action

阅读更多
今天首次使用Struts2,配置一切正常,使用常用tag也正常,但是在使用<s:form>标记时,发现控制台总是输出警告信息,

警告信息内容如下:

警告: No configuration found for the specified action: 'ShowMessage' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
2008-9-6 11:35:47 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
警告: No configuration found for the specified action: 'ShowMessage' in namespace: ''. Form action defaulting to 'action' attribute's literal value.

showmsg.jsp代码如下

<%@ 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>
......

struts.xml配置如下:
......
<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>

打开showmsg.jsp页面时,就出现上述异常。尝试了各种配置和访问方法,均出现警告。搜索网络给出的答案几乎都说把<s:form name="ShowMessage" method="post" action="/hello/ShowMessage.action" >中的.action去掉就可以解决了,做了测试,问题仍然没有解决。更有人让把<s:去掉,不用tag,直接写<form>这个当然不会有问题,但是一会用标记,一会不用,很杂乱,并且不是解决问题的根本之道。

解决方法:
经过测试发现,是没有正确使用tag的原因,这种情况下,正确的写法应该是,<s:form name="ShowMessage" method="post" action="ShowMessage" namespace="/hello" >


原因分析:

因为开始使用的struts2标签(form)并未指定namespace属性。所以struts2会默认从根命名空间"/" 搜索action '/hello/ShowMessage.action',如搜索不到则进入默认命名空间''搜索action串,在默认命名空间中是肯定找不到自己定义的action的,所以,struts2抛出一个警告信息。

现在我们指定了namespace为/hello,则struts2会直接在/hello命名空间寻找。可以想象,如果在这么命名空间里找不到请求的action,也会抛出一条类似的信息。

注意,<s:form name="ShowMessage" method="post" action="ShowMessage" namespace="/hello" >
不能写成<s:form name="ShowMessage" method="post" action="ShowMessage.action" namespace="/hello" >

这样仍然有对应的警告信息,并且提交后出现无法访问的结果。因为没有ShowMessage.action这样一个action,这个.action不能由我们手工添加,Struts2会自动为你完成这个工作,并且手工添加是不行的,就不必多此一举了。但是在其他的场合,比如使用超级链结,则可以加上这个.action。

分享到:
评论
9 楼 chenjunfei23 2012-04-24  
楼主很强大 
8 楼 vanceinfo_xuefei 2012-04-11  
如果在struts.xml中用的namespace就是默认的,在表单里面action就是"showMessage.action"还是出现了相同的警告怎么处理...
7 楼 过儿oO 2009-10-23  
我想问的是我在配置文件中没有配置namespace,那么在页面中的namespace应该写什么呢,我写了个“/”但是,那个问题还是出现
6 楼 cly_apple 2009-09-21  
我用的是 struts2-core-2.1.6.jar 。
按着上面布骤进行了还是有问题,那位弟兄知道法子吗?
5 楼 baozhengw 2009-01-11  
纠正一下,使用,<s:form name="ShowMessage" method="post" action="ShowMessage" namespace="/hello" >
是对的,刚才测试时有个form写成了<form>标签的,应该写成<s:form>
4 楼 baozhengw 2009-01-11  
使用,<s:form name="ShowMessage" method="post" action="ShowMessage" namespace="/hello" >
确实在查询的时候不出现warn的输出了,但提交时出现错误也面,如果写成,<s:form name="ShowMessage" method="post" action="ShowMessage.action" namespace="/hello" > ,则可以提交了,但warn又出来了,到底怎么做才对?
3 楼 javasunnyboy 2008-12-02  
俺也是转载的,呵呵,能帮到大家很开心!
2 楼 zhangwen_0707 2008-11-19  
谢谢了,以前也碰到因为没影响程序执行,今天同事也碰到我看了你的说明搞定了.
1 楼 tianzhijie11 2008-11-05  
谢谢了。刚好碰到这个问题,解决了

相关推荐

    Java邮件开发Fundamentals of the JavaMail API

    things like the last mail received and calculate how many are new for you. So, when using the JavaMail API, if you want this type of information, you have to calculate it yourself. IMAP IMAP is a...

    BURNINTEST--硬件检测工具

    - Minor changes to the No operation error watchdog timer for the CD and Hard disk tests. - Minor correction to the Butterfly seek test. - Video playback trace logging increased. Release 5.3 build ...

    OutlookAttachView v2.73

    o Added option to scan only emails with the specified 'From' and 'To' strings. * Version 1.82 o When adding a folder to scan (with the Add button), the folder path in now delimited with quotes, ...

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    For this reason, the functions that handle these actions offer the option of waiting until the action is complete before returning (so-called synchronous operation); although they can be called in an ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    is now available for writing (during the writing, the standard grid object TFlexGrid is released, and a user's one is set). - ADD: In the class TFlexGrid added the properties HOffset and VOffset - ...

    Turbo C 2.00[DISK]

    When /P is specified, the EGA palette will be restored each time the screen is swapped. In general, you don't need to use this switch unless your program modifies the EGA palette registers, or ...

    Turbo C 2.01[DISK]

    When /P is specified, the EGA palette will be restored each time the screen is swapped. In general, you don't need to use this switch unless your program modifies the EGA palette registers, or ...

    CE中文版-启点CE过NP中文.exe

    Fixed the found code dialog count size Fixed mono freezing Cheat Engine when it crashes/freezes Additions and changes: Changed the processlist and added an Applications view similar to the ...

    php.ini-development

    Please see the actual settings later in the document for more details as to why ; we recommend these changes in PHP's behavior. ; display_errors ; Default Value: On ; Development Value: On ; ...

    DebuggingWithGDB 6.8-2008

    4.1 Compiling for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Starting your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

Global site tag (gtag.js) - Google Analytics