我遵循Apache教程,但下面的代碼會出錯。如何在struts2中爲錯誤的動作請求設置默認頁面?
錯誤>>>>
Caused by: org.xml.sax.SAXParseException; systemId:
file:/C:/Users/target/Project-1.0/WEB-
INF/classes/struts.xml; lineNumber: 53; columnNumber: 15; The content of element type "package"
must match "(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-
class-ref?,global-results?,global-exception-mappings?,action*)".
請注意,行動和包正確定義爲一次,我把它複製到運行錯誤重定向代碼。 代碼
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="UnderConstruction"></default-action-ref>
<action name="UnderConstruction">
<result>notFound.jsp</result>
</action>
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action ....>
</action>
,,,
</package>
當我改變follwing線
<result>notFound.jsp</result>
到
<result type="tiles">notFound.jsp</result>
的應用程序將運行,但是當我輸入了錯誤的地址,它並不顯示notFound.jsp頁,只是拋出未找到的操作異常。
當我嘗試下面的代碼的應用程序運行,但它並沒有錯請求重定向到underconstruction頁面
<package name="default" namespace="/" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action ....>
</action>
,,,
</package>
<package name="Hello" extends="struts-default">
<default-action-ref name="UnderConstruction"></default-action-ref>
<action name="UnderConstruction">
<result>notFound.jsp</result>
</action>
</package>
的異常狀態明確什麼是錯的。 – 2013-03-13 14:18:45
@DaveNewton是的,但我想一切都是正確的,如問題中所示。我不知道什麼是錯的,我已經添加了以下行以及它運行,但是當我輸入一個錯誤的地址時,它不顯示notFound.jsp page notFound.jsp –
2013-03-14 01:33:52