Spring Boot☞ 使用velocity渲染web视图

效果图:

代码

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>Velocity模板</title>
</head>
<body>
Velocity模板
<h1>${host}</h1>
</body>
</html>

  

package com.wls.integrateplugs.velocity.controller;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
public class VelocityController {


@RequestMapping(value = "/helloVelocity",method = RequestMethod.GET)
public ModelAndView index(ModelMap map) {
ModelAndView mv = new ModelAndView("indexVelocity");
map.addAttribute("name","王老师");
map.addAttribute("host", "http://blog.didispace.com");
return mv;
}

}

  

posted @ 2017-09-07 00:21  air_balloon  阅读(690)  评论(0编辑  收藏  举报