標記時,發現控制臺總是輸出警告信息,警告信息內容如下:警告:Noconfigurationfoundforthespecifiedaction:'ShowMessage'innamespace:''.Formactiondefaultingto'action'a" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

No configuration found for the specified act

系統 2082 0

?

http://blog.csdn.net/carefree31441/article/details/4857546

?

使用 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。

No configuration found for the specified action解決辦法


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 扬州市| 临泽县| 永春县| 资溪县| 秀山| 永德县| 普宁市| 丹寨县| 固始县| 吴川市| 开原市| 浪卡子县| 香港 | 大埔县| 黑山县| 华阴市| 上饶市| 丹棱县| 北川| 和林格尔县| 杭锦后旗| 银川市| 萝北县| 将乐县| 济阳县| 高唐县| 昭觉县| 万山特区| 泸溪县| 会同县| 渝中区| 房产| 高尔夫| 监利县| 丹凤县| 沙坪坝区| 香河县| 泽普县| 武定县| 临邑县| 弥渡县|