直接添加一個starter
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetl-framework-starter</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
這個時候需要注意的有幾點:
1.在springboot的application.properties裏有些beetl的初始化屬性,最重要的是這個:
beetl.suffix = html
這個是什麼意思呢?
它的意思是當springmvc的view返回值以html結尾的時候,才使用beetl處理器解析模板
如下:
@RequestMapping("/beetl")
public String listGameOddrsForBeetl(HttpServletRequest request){
request.setAttribute("oddrses", oddsService.listGameOddrs());
return "aaa.jsp";
}
@RequestMapping("/beetl")
public String listGameOddrsForBeetl(HttpServletRequest request){
request.setAttribute("oddrses", oddsService.listGameOddrs());
return "aaa";
}
@RequestMapping("/beetl")
public String listGameOddrsForBeetl(HttpServletRequest request){
request.setAttribute("oddrses", oddsService.listGameOddrs());
return "aaa.html";
}
@ResponseBody
@RequestMapping("/beetl")
public String listGameOddrsForBeetl(HttpServletRequest request){
request.setAttribute("oddrses", oddsService.listGameOddrs());
return "aaa.html";
}
這裏第1/2都不會由beetl解析處理。
第四個上面有個json序列號註解,也不會由beetl解析。
只有第三個纔會。
2.springmvc-beetl的view默認是到classpath:templates下去找視圖
也就是說,如果你返回了aaa.html
那麼你的aaa.html要放在classpath:templates/aaa.html這個位置上。