zoukankan      html  css  js  c++  java
  • ajax向后台 controller传递参数

    function saveReportData(fileName,fileID) {
        console.log("fileName="+fileName);
        $.ajax({
            type : 'post',
            url : '${ctx}/reportmanage/specialReportManage/saveReportData',
            data:{'srFileName':fileName,"srFileID":fileID},
            traditional : true,
            async : false,        
            success : function(result){
                
            },
            error : function(result){
            }
        });    
    }

    接收方式两种

    •     说明:ajax的data参数名称(红色标识)必须和@RequestParam中的参数名称保持一致
    • @RequestMapping(value = "saveReportData")
    •     @ResponseBody

          public String saveReportData(@RequestParam(value = "srFileName", defaultValue = "") String FileName,
                  @RequestParam(value = "srFileID", defaultValue = "") String FileID) throws IOException {
              specialReportManageService.saveReportData(FileName, FileID);
              return "";
            }

    • 说明:如果没有添加@RequestParam,函数的参数名称必须和ajax中的参数名称一致
    • public String saveReportData( String srFileName,String srFileID) throws IOException {

              specialReportManageService.saveReportData(FileName, FileID);
              return "";
            }

  • 相关阅读:
    51Nod
    [HDU-5172] 单点查询线段树
    HihoCoder
    CodeForces
    计蒜客-T1271 完美K倍子数组
    [CodeForces-629A 用阶乘会爆掉
    计蒜客-A1139 dfs
    Codeforces Global Round 7 D2. Prefix-Suffix Palindrome (Hard version)(Manacher算法+输出回文字符串)
    HDU
    操作系统习题——虚地址转换为内存地址计算
  • 原文地址:https://www.cnblogs.com/tsx1230/p/8041683.html
Copyright © 2011-2022 走看看