pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
Controller
@Controllerpublic class PageController { @RequestMapping("/page") public String page3(Model model){ model.addAttribute("userName","张三"); return "hello"; } @RequestMapping("info/more") public String page2(){ return "hello2"; } @RequestMapping("sys/index") public String page(){ return "sys/index"; } @RequestMapping("/Hi") public ModelAndView sayHello() { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("hello"); modelAndView.addObject("key", 12345); //System.out.println("test"); return modelAndView; }}
resource/templates中添加vm