| | |
| | | package com.hx.util; |
| | | |
| | | import org.apache.commons.io.IOUtils; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | |
| | | */ |
| | | public class HttpServletRequestUtil { |
| | | |
| | | /* |
| | | /** |
| | | * 获取bady |
| | | * */ |
| | | public static String getBody(HttpServletRequest request) { |
| | | BufferedReader br = null; |
| | | StringBuilder sb = new StringBuilder(""); |
| | | String str ; |
| | | try { |
| | | br = request.getReader(); |
| | | while((str = br.readLine()) != null){ |
| | | sb.append(str); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | try { |
| | | if (null != br){ |
| | | br.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String wxMsgXml = null; |
| | | if(request == null){ |
| | | return wxMsgXml; |
| | | } |
| | | return sb.toString(); |
| | | try{ |
| | | wxMsgXml = IOUtils.toString(request.getInputStream(), |
| | | "utf-8"); |
| | | return wxMsgXml; |
| | | }catch (Exception e){ |
| | | wxMsgXml = null; |
| | | } |
| | | return wxMsgXml; |
| | | } |
| | | |
| | | |
| | | /* |
| | | /** |
| | | * |
| | | * 获取请求头 |
| | | * */ |