zoukankan      html  css  js  c++  java
  • 原生js:get和post请求

    前端get请求:
    function() {
         var href = "/platform_wechat/MedicalHome/update.do?id=" + id;       //地址以及传递的参数
         $.get(href, function(res) {  //res为接口返回数据
               if (res.success) {  
                     //请求成功处理业务
                }else{
                      //请求失败处理业务
               }
         }     
    
    }
    
    后端接口:
    
    @Controller
    @RequestMapping("/platform_wechat/MedicalHome")
    public class MedicalHomeAction {
        @RequestMapping(value = "update.do", method =RequestMethod.GET)
        @ResponseBody
        public Map<String,Object> update(String id){
            Map<String,Object> map = new HashMap<String, Object>();
         int result= appletConfigDao.update(id);
            if(result>0){
                map.put("success", true);
                map.put("info", "成功提示");
            }else{
                map.put("success", false);
                map.put("info", "失败提示");
            }
            return map;
        }
    
        //如果是查询数据直接返回一个实体类对象
    
    
    }
    
    
    post请求:
       function() {
        var href = "/platform_wechat/MedicalHome/update.do?id=" + id;       //地址以及传递的参数
        var params = {"id":""+id+"","authResult":"1","refuseText":"",};   //请求参数,写成键值对类型,键对应实体类的name,后端用实体类接受   
         $.post(href, params ,function(res) {  //res为接口返回数据
               if (res.success) {  
                     //请求成功处理业务
                }else{
                      //请求失败处理业务
               }
         }     
    
    }
    
    
    后端接口一样:
        method = POST   接收参数用实体类对象
  • 相关阅读:
    Convolution1D与Convolution2D区别
    git
    cast函数
    Ubuntu14.04编译WebRTC For Android代码 2014-07-24
    R语言基础-数组和列表
    疯狂的创业运动
    Autodesk 举办的 Revit 2015 二次开发速成( 1.5 天),教室培训, 地点武汉
    注冊(十一)重注冊带有鉴权信息
    ubuntu14.04无法安装Curl
    Bash脚本中的操作符
  • 原文地址:https://www.cnblogs.com/yydxh/p/13883319.html
Copyright © 2011-2022 走看看