Beetl和springboot整合

直接添加一个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这个位置上。

3.你可以在classpath下新建beetl.properties来具体配置。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章