qq_36910947 2017-12-02 03:12 采纳率: 0%
浏览 2437

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");
  • 写回答

4条回答 默认 最新

  • COCO_AS 2017-12-02 04:43
    关注

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

    评论

报告相同问题?