qqwer5655111
qqwer5655111
2017-01-09 09:52

Spring MVC中ajax请求失败

  • spring
  • ajax

ajax请求一直失败,实在看不出哪错了,后台可以获得请求数据,map里面都有值,但一到return,jsp页面就显示 ajax请求失败,,,求大神拯救

jsp页面

 $.ajax({
            cache:true,
            url:"oil/json.html",
            type:"get",
            data:$('#myForm').serialize(),
            dataType:"json",

            success:function(data){
                var d1 = data.rq; 
                var d2 = data.rcql;
                alert(d1);
                alert(d2);          
                    },
            error:function(){
                alert("ajax fail!") 
            }

        });

后台代码

 @RequestMapping(value="json.html")
    @ResponseBody
    public Map<String, List> getRqAndRcql(Oil oil,
            @RequestParam String jh,String startRq,String endRq,float scsj){
        Map<String, List> map1 = new HashMap<String, List>();
        List<String> rqs = new ArrayList<String>();
        List<Double> rcqls = new ArrayList<Double>();   
        //获得页面请求数据
        oil.setJh(jh);
        oil.setStartRq(startRq);
        oil.setEndRq(endRq);
        oil.setScsj(scsj);
        //调用业务层获得日期和日产气量
        List<Oil> list = obiz.getRqAndRcql(oil);
        //获得日产气量数组
        for (Oil oil2 : list) {
            rcqls.add(oil2.getRcql());
            System.out.println(oil2.getRcql());
        }
        //获得日期数组
        for (Oil oil2 : list) {
            rqs.add(oil2.getRq());
        }

        map1.put("rq", rqs);
        map1.put("rcqls", rcqls);
        return map1;
    }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答