2014-04-08 3 views
0

Java Struts를 처음 사용했습니다. 정확히 내가 무엇을 놓치고 있는지 확실하지 않습니다. 아래는 스택 추적은HTTP 상태 500 - 경로 친구가 "/"문자로 시작하지 않습니다.

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) 

스트럿-config 파일

<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

01 23,516,
<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

공용 클래스 LinkAction는 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"); 
} 

답변

0

path 속성 무수이어야한다. 이 논리는 ActionForward의 이름으로 캡슐화 인 자원 모듈 상대 경로 - struts-config_1.3.dtd

경로 장치. 이 값은 슬래시 ("/") 문자로 시작해야합니다.

타일 요청 프로세서를 사용하는 경우와 다릅니다. struts-config.xml에 다음 줄을 넣으십시오.

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

이 중 하나가 작동하지 않습니다. friends.js는 body.jsp에 타일로 삽입됩니다. – user99322

+0

나는 friends.js가 무엇인지 이해하지 못한다. 자바 스크립트인가요? –

+0

간단한 JSP 파일입니다. <% @ page contentType = "text/html"pageEncoding = "UTF-8"%> JSP 페이지

자세한 내용 ...

user99322