webService 接受提交的JSon数据

1、controller

@RequestMapping(value = "saveJson")
@ResponseBody
public Map saveJson(HttpServletRequest request) throws IOException {
		Map map = new HashMap();
		String submitMethod = request.getMethod();
		String data;
		if (submitMethod.equals("GET")) {
			data= new String(request.getQueryString().getBytes("iso-8859-1"),"utf-8").replaceAll("%22", "\"");
		} else {
			data= getRequestPostStr(request);
		}
                map.put("data",data);
                return map;
}
2、工具类

package com.thinkgem.jeesite.modules.util;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * Created by boxiaotong on 2017/1/17.
 */
public class RequestUtil {

    /**
     * 描述:获取 post 请求内容
     * 
     * 举例:
     * 
* @param request * @return * @throws IOException */ public static String getRequestPostStr(Http

你可能感兴趣的:(研发架构)