nginx中,前台使用ajax访问接口,传参数到后端接收为null,如何解决呢

如下是nginx的配置

 #前端界面
        location / {  
            root D:/ant-design-pro-master/dist;
            index  index.html index.htm;
        }
        #后端接口
        location ^~ /api/ {
            proxy_pass http://127.0.0.1:8085;
        }

axios传参代码如下

 axios.get(url, { params: { ID: 12345 }, })
    .then((response) => {
      console.log(response);
    })
    .catch((error) => {
      console.log(error);
    });

后台代码如下

 @RequestMapping(value = "${adminPath}/login", method = {RequestMethod.GET, RequestMethod.HEAD})
    public String login(HttpServletRequest request, HttpServletResponse response, Model model) {
        Map m = request.getParameterMap();
        String id = (String) request.getAttribute("ID");

把你的ajax相关代码和后端取参数的代码发上来看看

axios.get(url 这里的url写错了吧

request.getParameter("ID");

这样试试。

以下这三个url要一致,不知道你那都是啥,取参数要用request.getParamter而不是request.getAttribute

 /api/
url
${adminPath}/login