这是发的第三遍了……
问题:Struts-config.xml文件中action不能直接跳转已经配置好的Tiles定义,每次都报:“必须在路径前面加上‘/’”
现在是JSP页面<tiles:insert definition=“××××”>标签去引用Tiles定义是没有问题的,但是通过Struts-config.xml来跳转Tiles定义就失败了……具体例子如下:
struts-config.xml:
- XML code
<!-- Action Mappings --> <action-mappings> <action path="/search" type="action.SearchAction" name="searchForm" input="/jsp/search.jsp" validate="true" scope="request"> </action> <action path="/tilesTest" type="org.apache.struts.actions.ForwardAction" parameter="search.page" /> </action-mappings>
- XML code
<!-- Tiles Configuration --> <plug-in className="org.apache.struts.tiles.TilesPlugin"> <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" /> </plug-in>
tiles-defs.xml:
- XML code
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.3//EN" "http://struts.apache.org/dtds/tiles-config_1_3.dtd"><tiles-definitions> <!-- Main Layout --> <definition name="main.layout" path="/jsp/mainLayout.jsp"> <put name="title" value="" type="string"/> <put name="header" value="/jsp/header.jsp" /> <put name="body" value="" /> <put name="footer" value="/jsp/footer.jsp" /> </definition> <!-- Search Page --> <definition name="search.page" extends="main.layout"> <put name="title" value="Search Page" type="string"/> <put name="body" value="/jsp/search.jsp" /> </definition></tiles-definitions>
错误信息:
javax.servlet.ServletException: パス search.page が"/"文字で始まりません
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
请问各位Struts1.*的前辈,这是为什么呀?
------解决方案--------------------
应该是这样的