java.lang.IllegalArgumentException: Path index does not start with a "/" character


java.lang.IllegalArgumentException: Path index does not start with a "/" character
最近用struts的Tiles框架出現以下問題:
java.lang.IllegalArgumentException: Path index does not start with a "/" character 
查了好久才發現錯誤。

后來發現是 struts-config.xml中少配置了<controller>這一項,

配置了<controller>后,就一切正常了

<controller>
<set-property property="processorClass" value="org.apache.struts.tiles.TilesRequestProcessor"/>
</controller>

或者是

<controller>
<set-property property="inputForward" value="true"/>
</controller>

同時發現出現這樣的錯誤還有以下原因

1. struts-config.xml文件中<action-mappings /> 的

<action …… input="/xxx.jsp" ……   path="/XXX" ></action>

2.  問題出在使用getRequestDispatcher上面。

使用ServletContext.getRequestDispatcher(destPage);時destPage必須以相對路徑“/"出現。

而HttpServletRequest request.getRequestDispatcher(destPage);可以相對路徑也可以絕對路徑。

 

總之,希望大家今后在寫的時候要仔細。

 更多錯誤,請參閱 個人工作站:在這里網-前端技術博客


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM