警告: 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.
=============================== 华丽的分割线 ===============================
处理办法:
JSP正确写法
<s:form method="post" action="test1!add" namespace="/test">
struts.xml的正确配置
<struts>
<package name="default" namespace="/test" extends="struts-default">
<action>
…………
</action>
</package>
</struts>
原因分析:
使用的struts2标签<s:form>,并且未指定namespace属性。
所以struts2会默认从根命名空间"/" 搜索action 。
在默认命名空间中是肯定找不到自己定义的action的,
所以,struts2抛出一个警告信息。
指定namespace后,struts2会在指定的“/.....”命名空间找。
当然,如果在这个命名空间里找不到请求的action,也会抛出一条类似的信息。
注意!
<s:form name="name" method="post" action="test" namespace="/test" >
不能写成
<s:form name="name" method="post" action="test.action" namespace="/test" >
struts2会为我们自动补全的,无需手动添加,就不用多此一举了。
当然在其他地方,比如超链接,可以加.action。