2012-04-19 50 views
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> 

在此先感謝您的幫助。

回答

0

好吧,它現在的作品。對不起,這肯定是緩存問題。