“Circular view path” in a simple Spring Boot project with a Controller

前端 未结 3 1104
不思量自难忘°
不思量自难忘° 2021-02-06 00:34

I have a simple Spring Boot project with this Gradle build file:

apply plugin: \'java\'
apply plugin: \'eclipse\'
apply plugin: \'spring-boot\'
apply plugin: \'w         


        
相关标签:
3条回答
  • 2021-02-06 00:55

    You can use @RestController in your Spring Boot project instead of @Controller annotation. In this way you don't have to use @ResponseBody annotation in your method even if your method doesn't return any value.

    0 讨论(0)
  • 2021-02-06 01:12

    Adding @ResponseBody in your controller will solve this problem as below:

     public @ResponseBody void test() {
        }
    
    0 讨论(0)
  • 2021-02-06 01:20

    You've annotated the controller method as producing JSON, but it returns void. You probably want to annotate the method with @ResponseBody and change its return type to allow you to return an object representation of the JSON that you want to include in the response

    0 讨论(0)
提交回复
热议问题