警告信息內容如下:
警告: 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