Struts 2를 배우고 있습니다. FreeMarker 템플릿을 사용하여 뷰를 만드는 동안 오류가 발생합니다. 나는 이클립스 IDE를 사용하여 톰캣에서 응용 프로그램을 실행하고 8<@ s.generator 및 iterator 태그를 사용할 때 "Freemarker template error"가 나타나는 경우
프리 마커 코드 :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Sample...(FreeMarker)</h1><br><br>
<div>
<@s.generator separator="," val="%{'15,20,30,40,50'}">
Last entered protein Values -:<br>
<@s.iterator>
<@s.property /><br>
</@s.iterator>
</@s.generator>
</div>
</body>
</html>
이클립스 콘솔 추적 로그 :
> Jul 14, 2016 8:19:02 PM
> com.opensymphony.xwork2.util.logging.jdk.JdkLogger error SEVERE:
> Exception occurred during processing request: The following has
> evaluated to null or missing:
> ==> s.generator [in template "WEB-INF/content/enter-protein.ftl" at line 10, column 11]
>
> ---- Tip: It's the step after the last dot that caused this error, not those before it.
> ---- Tip: If the failing expression is known to be legally refer to something that's null or missing, either specify a default value like
> myOptionalVar!myDefault, or use <#if
> myOptionalVar??>when-present<#else>when-missing</#if>. (These only
> cover the last step of the expression; to cover the whole expression,
> use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
> ----
>
> ---- FTL stack trace ("~" means nesting-related):
> - Failed at: @s.generator separator="," val="%{'15... [in template "WEB-INF/content/enter-protein.ftl" at line 16, column 9]
> ---- FreeMarker template error: The following has evaluated to null or missing:
> ==> s.generator [in template "WEB-INF/content/enter-protein.ftl" at line 16, column 11]
>
> ---- Tip: It's the step after the last dot that caused this error, not those before it.
> ---- Tip: If the failing expression is known to be legally refer to something that's null or missing, either specify a default value like
> myOptionalVar!myDefault, or use <#if
> myOptionalVar??>when-present<#else>when-missing</#if>. (These only
> cover the last step of the expression; to cover the whole expression,
> use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
> ----
>
> ---- FTL stack trace ("~" means nesting-related):
> - Failed at: @s.generator separator="," val="%{'15... [in template "WEB-INF/content/enter-protein.ftl" at line 16, column 9]
> ----
>
> Java stack trace (for programmers):
> ---- freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at
> freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:116)
> at freemarker.core.UnifiedCall.accept(UnifiedCall.java:112) at
> freemarker.core.Environment.visit(Environment.java:312) at
> freemarker.core.MixedContent.accept(MixedContent.java:62) at
> freemarker.core.Environment.visit(Environment.java:312) at
> freemarker.core.Environment.process(Environment.java:290) at
> freemarker.template.Template.process(Template.java:312) at
> org.apache.struts2.views.freemarker.FreemarkerResult.doExecute(FreemarkerResult.java:223)
> at
> org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:191) at
.
.
.
.
........................ So on...........
이상한 일이며, 나는 JSP에서 동일 할 때 , 그것은 완벽하게 작동합니다! 는 <s:generator>
태그는 프리 마커 템플릿에서 사용할 수있는 태그 * 아니 그런 종류의 간단
그건 stackoverflow 내 첫 게시물을했다. 이 일이 언제 풀릴 지 궁금 했어. 너무 일찍 해결되었습니다. 감사. 나는 또한 당신이 저를 위해 그 참조를 제공했다는 것을 사랑했습니다. :) – hvsharma
@hvsharma 안녕하세요. 위대한 첫 번째 게시물. –
FreeMarker는 자체 iterator 지시어 ('# list' 및 그 친구들)를 가지고 있습니다 ... Struts의 베스트 프랙티스가 무엇인지 모르겠지만 이것은 나에게 이상하게 보입니다. – ddekany