一 概述
最近做个防火墙控制器,移动要求各个厂商接受参数名大小写不敏感,为了测试对接方面.
二 配置
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; }
测试结果: