Spring接受参数忽略参数名大小写敏感

一 概述

  最近做个防火墙控制器,移动要求各个厂商接受参数名大小写不敏感,为了测试对接方面.

二 配置

  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;
             
        }

 

 测试结果:

  Spring接受参数忽略参数名大小写敏感  

  

上一篇:linux上部署2.部署java程序


下一篇:jackson学习之五:JsonInclude注解