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

来源:互联网 发布:腾讯云和阿里云哪个牛 编辑:程序博客网 时间:2024/06/06 02:04
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);可以相对路径也可以绝对路径。

原创粉丝点击