zoukankan      html  css  js  c++  java
  • jeecg中ajax传值的前端js和后台代码

    前端js:

    var b=1;

    $.ajax({
    type : "POST",            --Post请求方式
    url : 'orderController.do?wuliao',    --路径
    crossDomain : true,          
    data: 'id='+b,            --传入的id值
    success : function(data) {
    data=data.replace("[","");      --返回的data数据
    data=data.replace("]","");
    var strs= new Array(); //定义一数组
    strs=data.split(","); //字符分割
      },
    error:function(){
    alert("系统错误!");
    }
    })

    后台代码:返回的是[aa,bb,cc]类型的

    @RequestMapping(params = "wuliao")
    @ResponseBody
    public void wuliao(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) throws IOException {
    String id=request.getParameter("id"); //接收传入的id值
    String aa= jdbcTemplate.queryForObject("select goods_name from wsc_goods where goods_id=?",String.class,Integer.parseInt(id));
    int bb=jdbcTemplate.queryForInt("select goods_price from wsc_goods where goods_id=?",Integer.parseInt(id));
    String cc=String.valueOf(bb);
    String dd= jdbcTemplate.queryForObject("select goods_code from wsc_goods where goods_id=?",String.class,Integer.parseInt(id));
    String ff= jdbcTemplate.queryForObject("select goods_model from wsc_goods where goods_id=?",String.class,Integer.parseInt(id));
    List<String> list = new ArrayList<String>();
    list.add(aa);
    list.add(cc);
    list.add(dd);
    list.add(ff);
    JSONArray array = new JSONArray();
    array.add(list);
    response.getWriter().write(list.toString());

    }

  • 相关阅读:
    c盘瘦身、windows解除上网限速、贴膜注意事项
    windows7导入k8s用户证书
    ubuntu报错解决和注意事项
    ubuntu默认root密码问题,第一次使用ubuntu需要设置root密码
    java程序员修炼之道
    选择器代码
    css的使用技巧资料
    移动开发的相关资料
    使用phantomjs生成网站快照
    PHP Simple HTML DOM Parser Manual-php解析DOM
  • 原文地址:https://www.cnblogs.com/xujiating/p/6374115.html
Copyright © 2011-2022 走看看