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>這一項,
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);可以相對路徑也可以絕對路徑。
總之,希望大家今后在寫的時候要仔細。
更多錯誤,請參閱 個人工作站:在這里網-前端技術博客