Adobe의 웹 사이트 (참조 용으로 코드 헤더에 표시된 링크)의 기사에 따라 간단한 서비스 레이어 인터페이스를 작성하려고합니다. 템플릿/구성 요소를 기반으로 페이지를로드하려고하면 오류가 발생합니다. [componentname] _jsp 유형의 메소드 [methodname]이 정의되지 않았습니다. 공공 및 액세스 수정 자, 다른 서명 및 반환 형식, 호출 코드 위에 메서드를 이동하고 항상 동일한 결과를 얻는 간단한 단일 메서드를 사용하여 시도했습니다. 메서드 이름을 주석 처리하고 중괄호로 묶은 블록으로 코드를 포함하면 OK가 컴파일됩니다. 이것이 CQ/AEM v5.6.1에서 가능하지 않거나 잘못된 것이 있습니까?구성 요소 .jsp에서 메소드를 사용할 수 있습니까?
아래와 같은 전체 코드 및 예외가 나와 있습니다 (여러 가지 실험 버전이 주석 처리되고 원래 getPath (...) 메소드가 생략되어 있음). 시간 내 미리 감사드립니다.
<%--
apipage component: implements service layer pages
see: http://blogs.adobe.com/contentmanagement/2012/08/19/how-to-integrate-with-other-web-services-without-creating-osgi-packages/
--%><%
%><%@include file="/libs/foundation/global.jsp"%>
<%@page import="org.apache.commons.httpclient.HttpClient,
org.apache.commons.httpclient.params.HttpClientParams,
org.apache.commons.httpclient.DefaultHttpMethodRetryHandler,
org.apache.commons.httpclient.methods.PostMethod,
org.json.JSONObject"
%><%@page session="false" %><%
%><%
if (request.getParameter("action") != null) {
if (request.getParameter("action").equals("getFields") &&
request.getParameter("param1") != null &&
request.getParameter("param2") != null) {
//response.setContentType("application/json");
// out.write(getPath((String)request.getParameter("param1"), (String)request.getParameter("param2"));
String str1 = "param1";
String str2 = "param2";
//out.write(getPath(str1, str2));
int i = doNothing();
}
} else {
response.setContentType("application/json");
out.write("{\"error\":\"error\"}");
}
/*public*/ int doNothing() {
return 1;
}
%>
Error during include of component '/apps/trp/components/layouts/apipage'
Error Message:
org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 24 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp
The method doNothing() is undefined for the type apipage_jsp
21: String str1 = "param1";
22: String str2 = "param2";
23: //out.write(getPath(str1, str2));
24: int i = doNothing();
25: }
26: } else {
27: response.setContentType("application/json");
An error occurred at line: 31 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp
Syntax error on token "int", new expected
28: out.write("{\"error\":\"error\"}");
29: }
30:
31: /*public*/ int doNothing() {
32: return 1;
33: }
34:
An error occurred at line: 31 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp
doNothing cannot be resolved to a type
28: out.write("{\"error\":\"error\"}");
29: }
30:
31: /*public*/ int doNothing() {
32: return 1;
33: }
34:
An error occurred at line: 31 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp
Syntax error, insert ";" to complete Statement
28: out.write("{\"error\":\"error\"}");
29: }
30:
31: /*public*/ int doNothing() {
32: return 1;
33: }
34:
An error occurred at line: 32 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp
Void methods cannot return a value
29: }
30:
31: /*public*/ int doNothing() {
32: return 1;
33: }
34:
35: /*
Processing Info:
Page = /content/trp/en/AfrescoAPI
Resource Path = /content/trp/en/AfrescoAPI/jcr:content
Cell = apipage
Cell Search Path = apipage
Component Path = /apps/trp/components/layouts/apipage
Sling Request Progress:
0 (2013-11-14 10:41:01) TIMER_START{Request Processing}
0 (2013-11-14 10:41:01) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message>
0 (2013-11-14 10:41:01) LOG Method=GET, PathInfo=/content/trp/en/AfrescoAPI.html
0 (2013-11-14 10:41:01) TIMER_START{ResourceResolution}
0 (2013-11-14 10:41:01) TIMER_END{0,ResourceResolution} URI=/content/trp/en/AfrescoAPI.html resolves to Resource=JcrNodeResource, type=cq:Page, superType=null, path=/content/trp/en/AfrescoAPI
0 (2013-11-14 10:41:01) LOG Resource Path Info: SlingRequestPathInfo: path='/content/trp/en/AfrescoAPI', selectorString='null', extension='html', suffix='null'
0 (2013-11-14 10:41:01) TIMER_START{ServletResolution}
0 (2013-11-14 10:41:01) TIMER_START{resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/trp/en/AfrescoAPI)}
0 (2013-11-14 10:41:01) TIMER_END{0,resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/trp/en/AfrescoAPI)} Using servlet /libs/foundation/components/primary/cq/Page/Page.jsp
0 (2013-11-14 10:41:01) TIMER_END{0,ServletResolution} URI=/content/trp/en/AfrescoAPI.html handled by Servlet=/libs/foundation/components/primary/cq/Page/Page.jsp
0 (2013-11-14 10:41:01) LOG Applying Requestfilters
0 (2013-11-14 10:41:01) LOG Calling filter: org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter
0 (2013-11-14 10:41:01) LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
0 (2013-11-14 10:41:01) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.designimporter.CanvasPageDeleteRequestFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.adobe.cq.history.impl.HistoryRequestFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.adobe.granite.optout.impl.OptOutFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.theme.impl.ThemeResolverFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet
0 (2013-11-14 10:41:01) LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter
0 (2013-11-14 10:41:01) LOG RedirectFilter did not redirect (MobileUtil.isMobileResource() returns false)
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.core.impl.warp.TimeWarpFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl
0 (2013-11-14 10:41:01) LOG Applying Componentfilters
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.personalization.impl.TargetComponentFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
0 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
0 (2013-11-14 10:41:01) TIMER_START{/libs/foundation/components/primary/cq/Page/Page.jsp#0}
0 (2013-11-14 10:41:01) LOG Including resource JcrNodeResource, type=trp/components/layouts/apipage, superType=null, path=/content/trp/en/AfrescoAPI/jcr:content (SlingRequestPathInfo: path='/content/trp/en/AfrescoAPI/jcr:content', selectorString='null', extension='html', suffix='null')
0 (2013-11-14 10:41:01) TIMER_START{resolveServlet(JcrNodeResource, type=trp/components/layouts/apipage, superType=null, path=/content/trp/en/AfrescoAPI/jcr:content)}
16 (2013-11-14 10:41:01) TIMER_END{16,resolveServlet(JcrNodeResource, type=trp/components/layouts/apipage, superType=null, path=/content/trp/en/AfrescoAPI/jcr:content)} Using servlet /apps/trp/components/layouts/apipage/apipage.jsp
16 (2013-11-14 10:41:01) LOG Applying Includefilters
16 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.personalization.impl.TargetComponentFilter
16 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
16 (2013-11-14 10:41:01) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
16 (2013-11-14 10:41:01) TIMER_START{/apps/trp/components/layouts/apipage/apipage.jsp#1}
156 (2013-11-14 10:41:01) LOG SCRIPT ERROR: org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class for JSP: //An error occurred at line: 24 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp/The method doNothing() is undefined for the type apipage_jsp/21: String str1 = "param1";/22: String str2 = "param2";/23: //out.write(getPath(str1, str2));/24: int i = doNothing();/25: }/26: } else {/27: response.setContentType("application/json");///An error occurred at line: 31 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp/Syntax error on token "int", new expected/28: out.write("{\"error\":\"error\"}");/29: }/30: /31: /*public*/ int doNothing() {/32: return 1;/33: }/34: ///An error occurred at line: 31 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp/doNothing cannot be resolved to a type/28: out.write("{\"error\":\"error\"}");/29: }/30: /31: /*public*/ int doNothing() {/32: return 1;/33: }/34: ///An error occurred at line: 31 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp/Syntax error, insert ";" to complete Statement/28: out.write("{\"error\":\"error\"}");/29: }/30: /31: /*public*/ int doNothing() {/32: return 1;/33: }/34: ///An error occurred at line: 32 in the jsp file: /apps/trp/components/layouts/apipage/apipage.jsp/Void methods cannot return a value/29: }/30: /31: /*public*/ int doNothing() {/32: return 1;/33: }/34: /35: /*/
156 (2013-11-14 10:41:01) TIMER_END{140,/apps/trp/components/layouts/apipage/apipage.jsp#1}
172 (2013-11-14 10:41:01) LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html],order=-1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=mobile, config=JcrPropertyMap [node=node /libs/cq/config/rewriter/default/transformer-mobile, values={component-optional=true, jcr:primaryType=nt:unstructured}]), Config(type=mobiledebug, config=JcrPropertyMap [node=node /libs/cq/config/rewriter/default/transformer-mobiledebug, values={component-optional=true, jcr:primaryType=nt:unstructured}]), Config(type=contentsync, config=JcrPropertyMap [node=node /libs/cq/config/rewriter/default/transformer-contentsync, values={component-optional=true, jcr:primaryType=nt:unstructured}]), serializer=Config(type=htmlwriter, config={}))}
172 (2013-11-14 10:41:01) TIMER_END{172,Request Processing} Dumping SlingRequestProgressTracker Entries