@Controller
可以直接 return jsp頁面和html頁面
如果需要返回json等內(nèi)容,需要加 @ResponseBody 注解
@RestController
直接返回json內(nèi)容 是 @ResponseBody & @Controller的組合
無法return jsp 頁面和 html 頁面
@CrossOrigin
允許接口跨域
@RequestMapping
提供路由信息
@RequestMapping(value = "/create",method = RequestMethod.POST)
- value:映射的請求URL或者其別名
- method:兼容HTTP的方法名
- params:根據(jù)HTTP參數(shù)的存在、缺省或值對請求進(jìn)行過濾
- header:根據(jù)HTTP Header的存在、缺省或值對請求進(jìn)行過濾
- consume:設(shè)定在HTTP請求正文中允許使用的媒體類型
- product:在HTTP響應(yīng)體中允許使用的媒體類型
@EnableAutoConfiguration
根據(jù)添加的jar包依賴自動(dòng)配置spring
- exclude 排除指定配置類
@SpringBootApplication
是@EnableAutoConfiguration & @ComponentScan & @Configuration的組合
自動(dòng)配置spring 和掃描當(dāng)前目錄下的所有包
@Configuration
導(dǎo)入其他配置類
@Autowired
注入構(gòu)造函數(shù)
@Service
標(biāo)注業(yè)務(wù)層組件