在字符模板中使用layout标签的问题

绿窗明月 发布于 2013/04/18 20:11
阅读 313
收藏 0

@闲.大赋 你好,想跟你请教个问题:

下边是使用模板的代码。模板里边有一部分内容需要动态生成,想使用layout标签来实现,动态内容作为layoutContent传进去,page.html里边是除了动态内容外固定的内容。但现在使用字符串模板时,调用layout标签总是报错,错误信息在代码下边。麻烦您看看

public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws Exception {
		response.setContentType("text/html;charset=UTF-8");
		String tplContent="<%layout(\"/page/page.html\"){%>动态内容<%}%>";
		GroupTemplate group=GroupTemplateUtil.getGroup();
		try {
			Template tpl=group.getStringTemplate(tplContent);
			tpl.getText(response.getOutputStream());
		} catch (BeeException e) {
			e.printStackTrace();
		}
		return null;
}
>>语法错:缺少符号LEFT_BRACE,0 行
1|<% layout("/page/page.html") %>
[B@1a59d9b3MismatchedTokenException(-1!=46)
	at org.bee.tl.core.BeeParser.recoverFromMismatchedToken(BeeParser.java:201)
	at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115)
	at org.bee.tl.core.BeeParser.statmentBlock(BeeParser.java:1498)
	at org.bee.tl.core.BeeParser.textProcessFunction(BeeParser.java:1212)
	at org.bee.tl.core.BeeParser.messFunction(BeeParser.java:1055)
	at org.bee.tl.core.BeeParser.statement(BeeParser.java:532)
	at org.bee.tl.core.BeeParser.statements(BeeParser.java:307)
	at org.bee.tl.core.BeeParser.prog(BeeParser.java:237)
	at org.bee.tl.core.CoreScriptRunner.parse(CoreScriptRunner.java:122)
	at org.bee.tl.core.BeeTemplate.initScriptRunner(BeeTemplate.java:138)
	at org.bee.tl.core.BeeTemplate.getTextByByteWriter(BeeTemplate.java:166)
	at org.bee.tl.core.AbstractTemplate.getText(AbstractTemplate.java:79)

加载中
0
闲大赋
闲大赋
layout("/page/page.html"){}
返回顶部
顶部