1、nginx中新增配置:
set $args "$args&参数名=参数值";
示例: set $args "$args&demo1=cn_yaojin&demo2=123123&myip=$remote_addr";
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
proxy_pass http://127.0.0.1:10024;
# 以下是在原来接口的基础上增加的固定参数
set $args "$args&demo1=cn_yaojin&demo2=123123&myip=$remote_addr";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
2、java代码测试效果
@ApiOperation(value = "test")
@GetMapping(value = "test")
public ResultMsg test() {
this.request.getParameterMap().forEach((k, v) -> {
for (String s : v) {
System.out.println(k + "--" + s);
}
});
return ResultMsg.builder();
}
3、查看实际效果: