zoukankan      html  css  js  c++  java
  • springMVC学习之接受JSON参数

    今天在springmvc使用rest模式异步提交,后台接受json字符。发现好多问题,感觉和spring3.0使用习惯上多少有点区别。因此把4.0的异步提交和方式记录下来。

    前台页面代码如下:

    <script type="text/javascript">
    $(function() {
      $("#btn").click(function() {
        var param = {firstUserId:"shaomch",secondUserId:"ramy",signId:"005",signType:"0005"};
        $.ajax({
          type: "post",
          url: "../WSHManager/mobile/feifanGroupIntentSign/createSign",
          dataType: "json",
          data: param,
          success: function (data) {
          }
        });
      });
    });
    </script>

    这里注意,以前传递到后台可能是json类型的字符串。现在可以直接传递json对象了。

    后台代码controller代码如下:

    /**
    * 取得对象形式接受json
    * @param param
    * @return
    */
    @RequestMapping(value = "createSign", method = RequestMethod.POST)
    public @ResponseBody BaseResult createSign(FeifanGroupIntentSignParam param) {
      //feifanGroupIntentSignService.createSign(param);
      return baseResult;
    }

    /**
    * 取得对象中的某个属性
    * @param param
    * @return
    */
    @RequestMapping(value = "createSign", method = RequestMethod.POST)
      public @ResponseBody BaseResult createSign(String firstUserId) {
      //feifanGroupIntentSignService.createSign(param);
      return baseResult;
    }

  • 相关阅读:
    编码器-解码器模型--本人实现
    Encoder-Decoder 架构实现
    一些数据集
    论文跟踪
    Densenet 实现
    多种卷积网络实现
    vs2019 指定项目输出目录和指定中间目录
    poi java读取excel文件
    eclipse配置tomcat添加外部项目
    eclipse配置tomcat
  • 原文地址:https://www.cnblogs.com/michaelShao/p/5525989.html
Copyright © 2011-2022 走看看