第一種:經過獲取緩衝流讀取參數html
public void registerUser(HttpServletRequest request, HttpServletResponse response)throws Exception { //直接獲取請求參數,經過緩衝流讀取數據 BufferedReader br=request.getReader(); String inputLine = ""; String json = ""; while ((inputLine = br.readLine()) != null) { json += inputLine; } br.close(); System.out.println(json); String result=mztManager.register(json); response.setContentType("text/html;charset=UTF-8"); response.getWriter().print(result); response.getWriter().flush(); }
第二種:經過ServletRequestUtils獲取java
String data = ServletRequestUtils.getStringParameter(request, "data", "");