`
_与狼共舞
  • 浏览: 59317 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

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

    博客分类:
  • Java
阅读更多
 
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>

实际中我是这样加的:

<controller nocache="true" inputForward="true" maxFileSize="2M" />

 

同时发现出现这样的错误还有以下原因

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

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

2.  问题出在使用getRequestDispatcher上面。

使用ServletContext.getRequestDispatcher(destPage);时destPage必须以相对路径“/"出现。

而HttpServletRequest request.getRequestDispatcher(destPage);可以相对路径也可以绝对路径。

 

总之,今后在写的时候要仔细。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics