4
我的模板被渲染,但没有freemarker处理。 输出为泽西岛 - Freemarker - 使用自定义ViewProcessor
<html>
<body>
<h1>Welcome ${user}</h1>
</body>
</html>
变量用户未被其值替换。
所以我不确定泽西知道一些关于我的自定义ViewProcessor。我如何明确地向Jersey表示我想使用Freemarker ViewProcessor。
我看到了下面的示例,但它并不能帮助 http://search.maven.org/#browse%7C-1697896452
综上所述,我有:
在我的pom.xml<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-freemarker</artifactId>
<version>1.12</version>
</dependency>
在我JerseyServletModule
Map<String, String> params = new HashMap<String, String>();
params.put("com.sun.jersey.freemarker.templateBasePath", "freemarker");
serve("/*").with(GuiceContainer.class, params);
在我的TestResource中
@Path("/test")
@GET
@Produces("text/html")
public Viewable getMytestView() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("user", "Peter");
return new Viewable("/test.ftl", map);
}
在我的src/main /资源/ freemarker的/ test.ftl
<html>
<body>
<h1>Welcome ${user}</h1>
</body>
</html>
在此先感谢您的帮助。