'HTTP Status 500 - Path friends does not start with a "/" character
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");
}
Solution 1:[1]
The path
attribute should be absolute. According to the struts-config_1.3.dtd
path - The module-relative path to the resources that is encapsulated by the logical name of this ActionForward. This value should begin with a slash ("/") character.
But it is different if you use a tiles request processor. Put the following line to the struts-config.xml
:
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |