博客
关于我
混合使用@RequestBody()和@RequestParam()
阅读量:369 次
发布时间:2019-03-04

本文共 886 字,大约阅读时间需要 2 分钟。

混合使用@RequestBody()和@RequestParam()

RequestParam参数放在前端ajax的url后用?连接,

RequestBody参数则是正常放在data中以json字符串形式传

var user = eval("("+sessionStorage.getItem("user")+")");        $.ajax({               url: "${pageContext.request.contextPath}/user/getMail?mailNum="+sessionStorage.getItem("mailNum"),            method: "post",            data: JSON.stringify(user),            datatype: "json",            contentType: "application/json",            xhrFields: {   withCredentials: true},//提供cookie信息            // success: function (res) {               //            // }        });//-----------------------------------后端代码    @RequestMapping("/getMail")    @ResponseBody    public HashMap
getMail(@RequestBody() User user,@RequestParam("mailNum") Integer mailNum){ HashMap
map = new HashMap
(); System.out.println(mailNum); return map; }

转载地址:http://nokg.baihongyu.com/

你可能感兴趣的文章
MySQL之2003-Can‘t connect to MySQL server on ‘localhost‘(10038)的解决办法
查看>>
MySQL之CRUD
查看>>
MySQL之DML
查看>>
Mysql之IN 和 Exists 用法
查看>>
MYSQL之REPLACE INTO和INSERT … ON DUPLICATE KEY UPDATE用法
查看>>
MySQL之SQL语句优化步骤
查看>>
MYSQL之union和order by分析([Err] 1221 - Incorrect usage of UNION and ORDER BY)
查看>>
Mysql之主从复制
查看>>