Struts1.3 使用Tiles框架中要注意的配置问题

  今天在测试tiles框架的时候,一个报错郁闷了我好久

   

javax.servlet.ServletException: java.lang.IllegalArgumentException: Path display.add.product.form does not start with a "/" character
通常出现这个报错的主要原因是action中设置forward元素跳转时候f跳转路径值前面忘记写"/"导致,不过很明显我的确是没有以/开头,但我现在用的是tiles框架做ui啊,跳转的并不是路径值,而是
指向tiles指定的xml文件中匹配的变量名而已,所以确定应该是tiles框架的配置出现了问题,所以它认为你forward要做的是一般的路径跳转动作而已。

查了一下,struts1.3跟之前的版本比较,标签库等的导入有了很大的改变。这里参考了struts文档的说明:
 
 

Here's how to use Tiles in your own application:

  • Ensure that a struts-tiles.jar is available in the WEB-INF/lib directory of your web application.
  • Add this init-param to the Action Servlet definition in web.xml:
        <init-param>
            <param-name>chainConfig</param-name>
            <param-value>org/apache/struts/tiles/chain-config.xml</param-value>
        </init-param>
        
  • Configure the Tiles Plugin to load your definitions.
        <plug-in className="org.apache.struts.tiles.TilesPlugin">
        <set-property
            property="definitions-config"
               value="/WEB-INF/tiles-defs.xml"/>
        </plug-in>
        
  • At the top of each JSP page that will use the Tiles custom tags, add a line that declares the Tiles custom tag library.
        <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
     
                           
    文档中说明了正确配置tiles框架的步骤,我缺少的正是第一步,在xml中加上了第一步,问题解决了。
    •     

转载于:https://www.cnblogs.com/SCAU_que/articles/2039389.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值