标签:获取参数
第一种:通过获取缓冲流读取参数
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获取
String data = ServletRequestUtils.getStringParameter(request, "data", "");
本文出自 “JianBo” 博客,转载请与作者联系!
标签:获取参数
原文地址:http://jianboli.blog.51cto.com/12075002/1908411