码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot取出信息

时间:2018-12-31 23:11:56      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:ack   adr   form   values   str   range   ring   mes   code   


1.打印头信息

@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ResponseBody
public List<UploadResult> upload(@RequestParam(name = "files", required = true) MultipartFile[] multipartFiles,
        @RequestHeader HttpHeaders httpHeaders,
        @RequestHeader(name = "content-range", required = false) String contentRange,
        @RequestHeader(name = "content-disposition", required = false) String contentDisposition,
        @RequestHeader(name = "Block-Index", required = false) Integer blockIndex,
        @RequestHeader(name = "Block-Total", required = false) Integer blockTotal,
        @RequestHeader(name = "Block-Done", required = false) String blockDone

)


System.out.println("-----------------------------------------------------------");
Iterator<String> headerNames = httpHeaders.keySet().iterator();
while (headerNames.hasNext()) {
    String key = headerNames.next();
    List<String> valueList = httpHeaders.getValuesAsList(key);
    String valueStr = "";
    for (String value : valueList) {
        valueStr += "|" + value;
    }
    System.out.println(key + "  -->  " + valueStr);
}


System.out.println("-----------------------------------------------------------");
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
    String key = headerNames.nextElement();
    String value = request.getHeader(key);
    System.out.println(key + "  -->  " + value);
}




2.打印form参数


Map<String, String[]> parameterMap = request.getParameterMap();
Iterator<Entry<String, String[]>> iterator = parameterMap.entrySet().iterator();
System.out.println("--form--------------------------");
while (iterator.hasNext()) {
    Entry<String, String[]> keyValues = iterator.next();
    String key = keyValues.getKey();
    String[] values = keyValues.getValue();
    System.out.println("--form--------------------------" + key + "  -->  ");
}

SpringBoot取出信息

标签:ack   adr   form   values   str   range   ring   mes   code   

原文地址:https://www.cnblogs.com/gispathfinder/p/10203523.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!