IT忍者神龟之Struts2.xml配置全然正确流程能走通可是有红叉解决
一:Multiple annotations found at this line:Undefined actionName ?parameter??Undefined actionnamespace ?parameter
這個紅色叉叉報錯:
Multiple annotations found at this line:
- Undefined actionName?parameter
- Undefined actionnamespace?
parameter
可是不影響功能,可是配置多了。非常難看
自己網上找了非常多類似的資料
這種錯誤的原因有非常多,我先列出我所知道的原因
另外一個是我自己項目的原因,我的原因就在于自己的第一個沒大寫
這是改完之后的圖
二:struts2.xml中使用chain和redirectAction這兩個注意事項
?當在struts.xml中使用chain和redirectAction這兩個類型結果的時候,會報檢查錯誤!
Multiple annotations found at this line:
????- Undefined actionnamespace
?????parameter
????- Undefined actionName parameter
相信不少朋友會被這個錯誤折騰的非常難受吧。如今說下解決方式,在百度和google上搜了非常久,國外站點也看了下,半天都沒找到解決方法。后來無意中在apache的站點上看到了struts2 chain的使用說明,細致讀了一下。就想到了一個辦法,也許能夠解決。于是就測試了一下,發(fā)現(xiàn)問題全然攻克了,如今來說下一我的解決方法。
chain結果類型有4個屬性,各自是:
????actionName (default) - the name of the action that will be chained to
????namespace - used to determine which namespace the Action is in that we're chaining. If namespace is null, this defaults to the current namespace
????method - used to specify another method on target action to be invoked. If null, this defaults to execute method
????skipActions - (optional) the list of comma separated action names for the actions that could be chained to
當中actionName和namespace是不可缺少的,否則就會報錯。所以我在項目中就寫成例如以下形式:
<package name="struts" extends="struts-default" namespace="/bg">
???????<action name="login" class="loginAction">
????????????<result type="chain">
????????????????<param name="actionName">index</param>
????????????????<param name="namespace">/bg</param>
????????????</result>
????????</action>
</package>
可是這么寫就有一個問題。我的項目比較簡單,不想使用命名空間。于是我就想怎么解決問題呢,在看官方文檔的時候我發(fā)現(xiàn)這么一句話:
A root namespace ("/") is also supported. The root is the namespace when a request directly under the context path is received. As with other namespaces, it will fall back to the default ("") namespace if a local action is not found.
于是我就想。用"/"取代"/bg"不就能夠解決這個問題了么。然后就把代碼寫成例如以下形式
<package name="struts" extends="struts-default" namespace="/">
???????<action name="login" class="loginAction">
????????????<result type="chain">
????????????????<param name="actionName">index</param>
????????????????<param name="namespace">/</param>
????????????</result>
????????</action>
</package>
好了講到這里我想大家也都明確了該怎么解決chain和redirectAction這兩個類型結果(type-result)報檢查錯誤(validation)的問題了吧!
有多的不正確的地方還請大家多多不吝賜教!
!
總結
以上是生活随笔為你收集整理的IT忍者神龟之Struts2.xml配置全然正确流程能走通可是有红叉解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Logstash+Redis+Elast
- 下一篇: bzoj 1901: Zju2112 D