这是我们正在研究的一个问题,在FINN.no 这就是我们希望组合模式(即Tiles提供)可以同时在服务器端和客户端工作。
今天我们采取一种简单的方法,在定义和属性名称的情况下,我们为此属性获取模板并将其重新渲染为客户端。我们为此使用胡子模板。
@RequestMapping(value = "template/{definitionName}/{attributeName:.+}", method = RequestMethod.GET)
public static void fetchTemplateDefinition(
@PathVariable("definitionName") String definitionName,
@PathVariable("attributeName") String attributeName,
HttpServletRequest httpRequest,
HttpServletResponse httpResponse) throws ServletException, IOException {
ApplicationContext tilesContext = ServletUtil.getApplicationContext(httpRequest.getSession().getServletContext());
TilesContainer tilesContainer = getTilesContainer(tilesContext);
ServletRequest servletRequest = new ServletRequest(tilesContext, httpRequest, httpResponse);
String templatePath = getTemplatePath(tilesContext, definitionName, attributeName, tilesContainer, servletRequest);
InputStream templateStream = loadResourceInputStream(templatePath, tilesContext);
IOUtils.copy(templateStream, httpResponse.getOutputStream());
}
Spring.addDecoration(..)看起来有趣!我需要阅读更多内容......
来源
2013-06-23 11:49:04
mck