tj
2025-06-05 2d549a04870d1315868a7cf19952b64e8071e711
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.cloudroam.common.configuration;
 
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValue;
import org.springframework.web.bind.ServletRequestDataBinder;
 
import javax.servlet.ServletRequest;
import java.util.LinkedList;
import java.util.List;
 
/**
 * @author 
 *
 * 自定义servlet请求参数绑定类
 */
 
public class CustomServletRequestDataBinder extends ServletRequestDataBinder {
 
    public CustomServletRequestDataBinder(final Object target) {
        super(target);
    }
 
    @Override
    protected void addBindValues(MutablePropertyValues mpvs, ServletRequest request) {
        List<PropertyValue> pvs = mpvs.getPropertyValueList();
        List<PropertyValue> adds = new LinkedList<>();
        for (PropertyValue pv : pvs) {
            String name = pv.getName();
            String camel = StringUtils.underlineToCamel(name);
            if (!name.equals(camel)) {
                adds.add(new PropertyValue(camel, pv.getValue()));
            }
        }
        pvs.addAll(adds);
    }
 
}