繁体   English   中英

HTTP 状态 500 - 路径好友不以“/”字符开头

[英]HTTP Status 500 - Path friends does not start with a “/” character

下面是错误:

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.

例外:

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文件:

<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");
}

path属性应该是绝对的。 根据struts-config_1.3.dtd

path - 由此 ActionForward 的逻辑名称封装的资源的模块相关路径。 此值应以斜杠 ("/") 字符开头。

但是,如果您使用图块请求处理器,则情况有所不同。 将以下行放入struts-config.xml

<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM