requesth获取参数

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
response.setCharacterEncoding("utf-8");
String token ;
token=request.getHeader("token");
System.out.println("当前用户请求头为:"+token);

String requestURI = request.getRequestURI();
Enumeration<String> em = request.getParameterNames();

System.out.println("current request meth:"+requestURI);
boolean b = em.hasMoreElements();
if(b){
String name = em.nextElement();
String value = request.getParameter(name);
System.out.println("form表单请求的参数名称:"+name+"请求的参数值:"+value);
}


BufferedReader br = request.getReader();
String str, wholeStr = "";
while((str = br.readLine()) != null){
wholeStr += str;
}
System.out.println("body--Json中请求的参数名称:"+wholeStr);

}
posted @ 2018-06-28 18:08  wlhebut  阅读(162)  评论(0编辑  收藏  举报