<!-- https://mvnrepository.com/artifact/org.inurl/inurl-spring-ext -->
<dependency>
<groupId>org.inurl</groupId>
<artifactId>inurl-spring-ext</artifactId>
<version>1.0.0</version>
</dependency>
- org.inurl.spring.ext.bind.ModelRequestParamProcessor
- org.inurl.spring.ext.bind.ModelRequestParam
参考https://stackoverflow.com/a/16520399
// WebMvcConfiguration.java
@Configuration
public class WebMvcConfiguration {
@Bean
public ModelRequestParamProcessor modelRequestParamProcessor() {
return new ModelRequestParamProcessor();
}
}
// TestModel.java
public class TestModel {
private String a;
@ModelRequestParam("b")
private String c;
@ModelRequestParam(name = "y")
private int z;
//... setter and getter
}
// TestController.java
@RestController
public class TestController {
@GetMapping("/test")
public TestModel test(TestModel param) {
return param;
}
}
// GET /test?a=1&b=2&y=3
// OUTPUT => { "a": "1", "c": "2", "z": 3 }