Below is the error:
HTTP Status 500 - Path friends does not start with a "/" character
type Exception report
message Path friends does not start with a "/" character
description The server encountered an internal error that prevented it from fulfilling this request.
Exception:
java.lang.IllegalArgumentException: Path friends does not start with a "/" character
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1074)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:396)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:347)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
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:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
struts-config.xml
file:
<action-mappings>
<action path="/Link" parameter="method" type="com.vaannila.LinkAction">
<forward name="friends" path="friends"/>
<forward name="office" path="office"/>
</action>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>
menu.jsp
:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<a href="Link.do?method=friends" >Friends</a><br>
<a href="Link.do?method=office" >The Office</a>
</body>
</html>
baseLayout.jsp
:
<body>
<table border="1" cellpadding="2" cellspacing="2" align="center">
<tr>
<td height="20%" colspan="2">
<tiles:insert attribute="header" ignore="true" />
</td>
</tr>
<tr>
<td width="20%" height="250">
<tiles:insert attribute="menu" />
</td>
<td>
<tiles:insert attribute="body" />
</td>
</tr>
<tr>
<td height="20%" colspan="2">
<tiles:insert attribute="footer" />
</td>
</tr>
</table>
</body>
</html>
index.jsp
:
<tiles:insert page="/baseLayout.jsp" flush="true">
<tiles:put name="title" value="Tiles Example" />
<tiles:put name="header" value="/header.jsp" />
<tiles:put name="menu" value="/menu.jsp" />
<tiles:put name="body" value="/body.jsp" />
<tiles:put name="footer" value="/footer.jsp" />
</tiles:insert>
LinkAction.java
:
public class LinkAction extends DispatchAction {
/**
* This is the Struts action method called on
* http://.../actionPath?method=myAction1,
* where "method" is the value specified in <action> element :
* ( <action parameter="method" .../> )
*/
public ActionForward friends(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("friends");
}
/**
* This is the Struts action method called on
* http://.../actionPath?method=myAction2,
* where "method" is the value specified in <action> element :
* ( <action parameter="method" .../> )
*/
public ActionForward office(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("office");
}
1条答案
按热度按时间ivqmmu1c1#
path
属性应该是绝对的.根据struts-config_1.3.dtd
path -此ActionForward的逻辑名称封装的资源的模块相对路径。此值应以斜杠(“/”)字符开始。
但如果使用tiles请求处理器,则情况会有所不同。