zoukankan      html  css  js  c++  java
  • 关于ajax的与后台Controller的交互 后台拿不到值

    话不多说 上代码 

     这是前段js的代码        传的两个参数    cLassid  和  userid

    $.ajax({
        		type:"post",
        		url:"../classsetting/addCounselor.do",
        		data:{"cLassid": cLassid, "userid": userid},
        		dataType:"json",
    //    		contentType:"application/json;charset=UTF-8",
        		async:false,
        		success:function(data){
        		              ......  
        		},error:function(jqXHR, textStatus, errorThrown){
        			.......
        		}
           });
    

    后台代码 如下 

            @RequestMapping(value = "addCounselor.do" )
    	public @ResponseBody int insertCounselor(HttpServletRequest request) {
    		String classid  = request.getParameter("cLassid");//编辑编号
    		String counselor  = request.getParameter("userid");//辅导员的 userID
              //拿不到 ajax的 参数!!!! 原因在下面 int i = sysClassService.updateClassCounselor(counselor,classid); return i; }

      

    结论! 为何会拿不带呢  ?  原因在于我的 Ajax  

       contentType:"application/json;charset=UTF-8"   //这行代码要删掉

          未更新完 待续。。。

  • 相关阅读:
    7-30-组队赛
    POJ 3125 Printer Queue
    7-28-比赛
    POJ 3922 A simple stone game
    POJ 1845
    第一次组队训练
    I-number
    Radar Installation
    Robots on a grid(DP+bfs())
    Dividing a Chocolate(zoj 2705)
  • 原文地址:https://www.cnblogs.com/shundong106/p/10254990.html
Copyright © 2011-2022 走看看