Annotated a class with @Configuration and @Controller. Need help in refactoring

前端 未结 6 611
一整个雨季
一整个雨季 2021-01-17 15:49

Below is my class in which i had to use both @Configuration and @Controller as there should be only one instance of Thymeleaf in the e

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 16:17

    Assuming you're using Spring Boot, since you have it in tags, you do not need any configuration to use Thymeleaf.

    By just having this dependency, you can:

    @GetMapping("/view-template")
    public String viewTemplates(Model model) {
        model.addAttribute("mydata", "this is it")
        return "view-to-process";
    }
    

    And it should work.

    By the way, yes, having @Configuration and @Controller in the same class is something you should never need.

提交回复
热议问题