Springboot基础知识

1、@RestController注解

  • Spring4之后新加入的注解,@RestController是@ResponseBody和@Controller的组合注解。(返回json需要@ResponseBody和@Controller配合)
  • pom.xml依赖
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
  • 在POM中加入spring-boot-starter-web依赖, @RestController还是不能用的解决方法:手动导入包。
import org.springframework.web.bind.annotation.RestController; 

猜你喜欢

转载自www.cnblogs.com/gavincoder/p/10068433.html