struts2接收请求参数的问题

jianglu188 发布于 2013/08/17 16:07
阅读 303
收藏 1

使用$.ajax post一个json数据的时候 {"list":{"deleted":[],"inserted":[],"updated":[{"_id":"9903","menuName":"组织结构","menuCode":"990311","parentCode":"99","iconClass":"icon-org","url":"./sys/organize.html","isVisible":"false","isEnable":"false","menuSeq":"220"}],"_changed":true}} chrome里面看到请求如下图 在struts action里面如何取请求参数 

HttpServletRequest request = ServletActionContext.getRequest();
		StringBuilder sb = new StringBuilder();
		try {
			ServletInputStream inputStream = request.getInputStream();
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					inputStream));
			String line = null;
			while ((line = reader.readLine()) != null) {
				sb.append(line);
				logger.info(line);
				System.out.println(line);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		logger.info("request:" + sb.toString());
试了这样子是取不到 请大神指点

加载中
0
52java
52java
没这么写过。你要讲json里面的属性封装成action中的属性
0
laigous
laigous
ajax 里用data:{datas:'josn数据'} action 直接用datas就能获得
返回顶部
顶部