SpringBoot雞湯(註解集合二)
阿新 • • 發佈:2017-12-22
lis aps clas lap cti boot value 請求 app
1.@NotNull :屬性值不為空
2.@Profiles
@Configuration @Profile("production") public class ProductionConfiguration { // ... }
3.@PathVariable是用來獲得請求url中的動態參數的
例子:
@RestController @RequestMapping(value=”/users”) public class MyRestController { @RequestMapping(value=”/{user}”, method=RequestMethod.GET) public User getUser(@PathVariable Long user) { // … } @RequestMapping(value=”/{user}/customers”, method=RequestMethod.GET) List getUserCustomers(@PathVariable Long user) { // … } @RequestMapping(value=”/{user}”, method=RequestMethod.DELETE) public User deleteUser(@PathVariable Long user) { // … } }
SpringBoot雞湯(註解集合二)