requesth获取参数
Posted wlhebut
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);
}
以上是关于requesth获取参数的主要内容,如果未能解决你的问题,请参考以下文章