SoFunction
Updated on 2025-03-10

Summary of controller parameter mapping problem in springboot

The class and json parameters I use to receive parameters are shown below

public class ExtendedInformation {
    String customerItemName;
    String operation;
    public String getWaferLot() {
      return customerItemName;
    }
    public void setWaferLot(String customerItemName) {
       = customerItemName;
    }
    public String getOperation() {
      return operation;
    }
    public void setOperation(String operation) {
       = operation;
    }
  }
{
    "operation": "TEST",
    "customerItemName": "TEST"
}

Then I found that the customerItemName parameter map cannot be

It turns out that it is the getter of my customerItemName property, the setter method name is getWaferLot/setWaferLot, and my json parameter does not have WaferLot, which causes the mapping to be unable to be made.

Change it to the following json parameter and it can be successfully mapped.

{
    "operation": "TEST",
    "waferLot": "TEST"
}

Summary: When mapping the parameter, we find the corresponding setter method based on the parameter name we send and assign attributes.

1. If we use lombok annotation, we will generate the getter/setter method corresponding to the object attribute name. Our sending parameters are just as good as the object attribute name.

2. If we customize the setter method, we must ensure that our sending parameters can be mapped with the setter method, such as setxxx and {'xxx':''}

This is the end of this article about springboot controller parameter mapping problem. For more related springboot controller parameter mapping content, please search for my previous article or continue browsing the related articles below. I hope everyone will support me in the future!