Thymeleaf
在IDEA中,新创建一个文件,进行搞Thymeleaf这个东西,不要有@RequestBoby注解,这个注解自动把函数返回值转化成json格式,可是Thymeleaf只接受字符串,所以,你的不显示
Thymeleaf只能下面2种搭配方式
@Controller
public class ListController {
// 下面是视图解析器测试内容
// 11-25日,17:25 运行成功!!!
@GetMapping ("/list/ViewTest/{name}")
public String viewTest(@PathVariable(value = "name")String name, Model model) {
model.addAttribute("message", "hello,world "+name);
return "list";
}
}
@RestController
public class IndexController {
@GetMapping("/index")
public ModelAndView index(){
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("index");
return modelAndView;
}
}
如果对你有帮助,请关注我哦