springboot中controller不能跳转templates的原因

@RestController
public class HelloController {

    @RequestMapping("/test")
    public String test(Model model) {
        model.addAttribute("msg","hello springboot");
        return "test";
    }
}

<!DOCTYPE html>
<html lang = "en" xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset = "UTF-8">
    <title>Title</title>
</head>
<body>
<div th:text="${msg}"></div>
</body>
</html>

按道理是可以直接在浏览器中显示hello springboot的。但是在浏览器地址栏中却发现跳转不到test.HTML。
具体原因:@RestController 这个注解。把这个注解改成@Controller就可以跳转了。

具体原因我还在摸索中,如果有朋友知道的也可以私信我。


版权声明:本文为weixin_45255645原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。