struts2的namespace的一些总结
在struts2中经常会出现一个关于namespace的警告:类似 No configuration found for the specified action: 'validation.action' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.
这个警告出现的原因一般是关于命名空间的,出现这种警告的可能问题是:
1、<s:form name="ShowMessage" method="post" action="ShowMessage.action">提交表单的时候,自己加了.action后缀,修改为<s:form name="ShowMessage" method="post" action="ShowMessage">
2、如果还有类似的警告,这有可能是在
truts.xml的配置中增加了命名空间:?如
<struts>?
<package name="hello" extends="struts-default" namespace="/hello">?
<action name="ShowMessage" method="post" action="/hello/ShowMessage.action" > ,这个时候也会出现类似的警告。
修改为<s:form name="ShowMessage" method="post" action="ShowMessage" namespace="/hello" >
建议如果添加了命名空间,最好在webRoot下建一个和命名空间同名的文件夹,将这个命名空间下用到的jsp页面放入其中,这样可以减少一些不必要的麻烦。