Spring MVC 下以JSON格式向后抬传数据
来源:互联网 发布:为什么mac不能玩lol 编辑:程序博客网 时间:2024/06/11 11:23
json 格式:
{type:1, appKey: "aaa", sign: "bbb"}
后台代码:
<span style="white-space:pre"></span>@RequestMapping(value="/getEventList", method=RequestMethod.POST)@ResponseBodypublic Object getEventList(@RequestBody Map<String, Object> map){logger.info("test");logger.info(map.get("type"));Map<String, Object> json = new HashMap<String, Object>();json.put("code", "200");return json;}
前台代码:
function dojson(){$.ajax({type: "post",dataType:"json",contentType: "application/json;charset=utf-8", url: "<%=basePath%>getEventList",data: JSON.stringify({type:1, appKey: "aaa", sign: "bbb"}), success: function (result) { }});}
json 格式:
{type:1, productList:[{productId:1,stock:1},{productId:2,stock:2}]}
后台代码:
<span></span>@RequestMapping(value="/getEventList", method=RequestMethod.POST)@ResponseBodypublic Object getEventList(@RequestBody Map<String, Object> map){logger.info("test");logger.info(map.get("type"));List<LinkedHashMap<String, Object>> lista = (List<LinkedHashMap<String, Object>>) map.get("productList");System.out.println(lista.get(0).get("productId"));System.out.println(lista.get(0).get("stock"));Map<String, Object> json = new HashMap<String, Object>();json.put("code", "200");return json;}
前台代码:
function dojson(){$.ajax({type: "post",dataType:"json",contentType: "application/json;charset=utf-8", <span style="white-space:pre"></span>url: "<%=basePath%>getEventList",data: JSON.stringify({type:1, productList:[{productId:1,stock:1},{productId:2,stock:2}]}), success: function (result) { }});}
0 0
- Spring MVC 下以JSON格式向后抬传数据
- spring MVC框架下Controller发送JSON格式的数据
- 封装Spring MVC 返回JSON 格式数据
- Spring MVC接受JSON格式的数据
- Spring MVC返回JSON格式的数据
- Spring MVC接受JSON格式的数据
- Spring MVC返回JSON格式的数据
- java以json格式向后台服务器接口发送请求
- 使用spring MVC返回json格式的数据
- spring mvc 返回json格式数据的方式
- spring MVC 中json格式数据发送与接收
- spring mvc实现Restful返回json格式数据
- spring mvc 对返回json格式数据的支持
- spring MVC 中json格式数据发送与接收
- 使用spring-mvc 框架返回json格式数据 报406
- spring mvc实现Restful返回json格式数据
- Spring MVC 实现RESTful 返回JSON格式数据
- SPRING MVC 返回数据自动转换为JSON格式
- 堆排序
- 【OpenGL】详解第一个OpenGL程序
- Android JNI和NDK有什么区别
- Linux内核学习9:多线程程序设计
- 数据挖掘领域顶级会议期刊及其分析
- Spring MVC 下以JSON格式向后抬传数据
- hdu1710 Binary Tree Traversals
- A definition for the symbol '<symbolName>' could not be located
- SAP 后台数据表记录删除的三种方法
- [LeetCode]Maximum Product Subarray
- Bestcoder #11
- 多字节存储顺序
- 基于多播实现的android手机户外对讲APP
- Lex and Yacc