Spring Boot筆記——2
項目屬性配置
application.properties
application.yml
———————————————————————————————————————————
———————————————————————————————————————————
———————————————————————————————————————————
———————————————————————————————————————————
———————————————————————————————————————————
注解
@Value("${cupSize}")
private String cupSize;
@Value("${age}")
private Integer age;
————————————
@Component
@ConfigurationProperties(prefix = "girl")
@Autowired
———————————————————————————————————————————
Controller的使用
@Controller 處理http請求
@RestController Spring4之後新加的注解,原來返回json需要@ResponseBody配合@Controller
@ResquestMapping 配置url映射
———————————————————————————————————————————
———————————————————————————————————————————
@PathVariable 獲取url中的數據
@RequestParam 獲取請求參數的值
@GetMapping 組合注解
@PostMapping 組合注解
最後更新:2017-06-22 21:02:06