나는 서버 측에서 freemarker ftl 파일을 처리하고 HTML을 클라이언트로 되돌려 줄 것을 요구한다. template.process()를 사용하여 struts 태그가있는 freemaker 템플릿을 처리 할 수 있는지 알고 싶습니다.freemarker 템플릿에서 struts2 태그 처리하기
Action 클래스 코드 :
// Configuration created from struts2 freemarkermanager
FreemarkerManager freeMarkerManager = new FreemarkerManager();
Configuration config = freeMarkerManager.getConfiguration(context);
//Configuration without any specific settings.
Configuration config = new Configuration();
//Tried both nothing works.
Template template = config.getTemplate("TEMPLATE PATH");
Map<String, Object> inputMap = new HashMap<String, Object>();
inputMap.put("document", document);
StringWriter output = new StringWriter();
template.process(inputMap, output);
프리 마커 템플릿 :
<#assign s=JspTaglibs["/struts-tags"]>
<table>
<tr>
<th><@s.text name="Document Name"/></th>
<th><@s.text name="Description"/></th>
</tr>
<@s.iterator value="inspiration" status="status">
<tr>
<td class="nowrap"><@s.property value="properties.DOCUMENT_NAME"/></td>
<td class="nowrap"><@s.property value="properties.DESCRIPTION"/></td>
</tr>
</@s.iterator>
</table>
는 또한 WEB-INF 폴더 아래에 스트럿 - tags.tld을 추가했습니다.
예외
freemarker.core.InvalidReferenceException : 식 JspTaglibs은, 라인 (1)에 정의되어 있지 I은 < #assign의 S 개의 =의 JspTaglibs 제거하면
[ "/ 스트럿 - 태그"] "
freemarker.core.InvalidReferenceException : 표현식 s는 7 행에서 정의되지 않았습니다.
은 분명히 그것은 * * 가능합니다. JSP를 지원하려면 더 많은 설정이 필요합니다. 소스 또는 FM 문서를 확인하십시오. –
FreeMarkerResult를 사용자 지정하는 예제가 있습니까? –
왜 FreeMarker 결과를 사용자 정의해야합니까? 결과를 사용하지 않고 있습니다. 나는 FM 템플리트의 결과를 조치의 일부로 리턴하지만 FM 결과를 사용하지 않을 경우 수행하려는 작업을 이해하지 못합니다. –