一 概述
最近做個防火牆控制器,移動要求各個廠商接受參數名大小寫不敏感,為了測試對接方面.
二 配置
1 pom文件引入(springboot版本2.4.0)
<dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.13</version> </dependency>
2 yml文件配置(忽略參數名大小寫不敏感spring.jackson.mapper.accept-case-insensitive-properties=true)
spring: jackson: mapper: accept-case-insensitive-properties: true
3實體類
@Data @AllArgsConstructor @NoArgsConstructor public class People { private String Name; private int age; }
4 postman測試()
{ "name":"tom", "AGE" :25 }
Controller層:
@PostMapping @ResponseStatus(HttpStatus.CREATED) public String createSecurityPolicy(@RequestBody People people) { System.out.println("name=="+people.getName()); System.out.println("age=="+people.getAge()); return null; }
測試結果: