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) {
// …
}
}
本文详细介绍了Spring框架中常用的注解,如@NotNull、@Profiles和@Configuration等的作用及用法,并通过实例展示了如何使用@PathVariable获取URL中的动态参数。
27万+

被折叠的 条评论
为什么被折叠?



