警告信息内容如下:
警告: No configuration found for the specified act
2008-9-6 11:35:47 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
警告: No configuration found for the specified act
showmsg.jsp代码如下
<%@ taglib prefix="s" uri="/struts-tags" %>
......
<div>
hello world
<s:form name="ShowMessage" method="post" act
<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">
<act
<result>/digg/showmsg.jsp</result>
</act
</package>
</struts>
打开showmsg.jsp页面时,就出现上述异常。尝试了各种配置和访问方法,均出现警告。搜索网络给出的答案几乎都说把<s:form name="ShowMessage" method="post" act
解决方法:
经过测试发现,是没有正确使用tag的原因,这种情况下,正确的写法应该是,<s:form name="ShowMessage" method="post" act
原因分析:
因为开始使用的struts2标签(form)并未指定namespace属性。所以struts2会默认从根命名空间"/" 搜索act
现在我们指定了namespace为/hello,则struts2会直接在/hello命名空间寻找。可以想象,如果在这么命名空间里找不到请求的act
注意,<s:form name="ShowMessage" method="post" act
不能写成<s:form name="ShowMessage" method="post" act
这样仍然有对应的警告信息,并且提交后出现无法访问的结果。因为没有ShowMessage.act
此博客内容转载 historycreator.com