springboot @RestController 注解 说明

springboot @RestController 注解 说明

在java代码里面加上RestController 表示修饰Controller所有的方法返回JSON格式,直接可以编写Restful接口

注意该注解是SpringMVC提供的哦!

 

@RestController
@EnableAutoConfiguration
public class HelloController {
    @RequestMapping("/hello")
    public String index() {
        return "Hello World";
    }    
public static void main(String[] args) {
        SpringApplication.run(HelloController.class, args);
    }
}

 

posted @ 2022-12-08 20:17  谢端阳  阅读(96)  评论(0编辑  收藏  举报