【发布时间】:2018-01-09 14:57:11
【问题描述】:
有没有办法将这两个值封装到一个对象中?
public ResponseEntity<TestResponse> test(@PathVariable("customerId") String customerId,
@RequestParam(name = "reason", required = true) String reason,
@RequestParam(name = "attribute", required = true) List<String> attributes) {
我认为我应该可以这样做:
public ResponseEntity<TestResponse> test(@MaybeSomeMagicAnnotation? Request request) {
Request 类具有这三个属性(customerId、reason、attributes)。
我使用的是 spring boot 1.5.9
【问题讨论】:
-
你不需要任何东西。只需创建具有这三个字段的 Request 类并将其用作方法参数。
标签: java spring spring-mvc spring-boot request-mapping