标签:
$(function () { $('#saveMenu').on('click', function () { var data = { button: dataCondense(menuList.toJSON()) } $.ajax({ method: 'POST', url: '/weixin/saveMenu', contentType:'text/html', data: JSON.stringify(data), success: function (data) { // todo } }) console.log(JSON.stringify(data)) }) })
若要传送json到struts必须使用JSON.stringify(),否则在struts2中获取的是键值对,如下获取键值对
Enumeration<String> enumeration = request.getParameterNames(); while(enumeration.hasMoreElements()){ String key = enumeration.nextElement(); System.out.println(key+"======"+request.getParameter(key)); }
HttpServletRequest request = ServletActionContext.getRequest(); request.setCharacterEncoding("UTF-8"); BufferedReader br = new BufferedReader(new InputStreamReader( request.getInputStream())); StringBuffer sb = new StringBuffer(); String str = null; while ((str = br.readLine()) != null) { sb.append(str); }
标签:
原文地址:http://blog.csdn.net/hackcoder/article/details/44860791