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   接收参数用实体类对象
  • 相关阅读:
    re模块
    collections模块
    hashlib模块
    序列号模块
    random模块
    sys模块
    OS模块
    工厂模式
    Go语言之直接选择排序
    Go语言之直接插入排序
  • 原文地址:https://www.cnblogs.com/yydxh/p/13883319.html
Copyright © 2011-2022 走看看