In the HTTP request, there is the header and the body of the points, read the header using Request.getheader ("...");
The read body uses Request.getreader (), but Getreader gets the BufferedReader and needs to convert it to a string, the following is the method of conversion.
Public classTestController {@RequestMapping ("/A") protected voidDoPost (httpservletrequest request, httpservletresponse response, BufferedReader BR)throwsServletexception, IOException {
Header section System.out.print (Request.getheadernames ()); Enumeration<?> ENUM1 =Request.getheadernames (); while(Enum1.hasmoreelements ()) {String key=(String) enum1.nextelement (); String value=Request.getheader (key); SYSTEM.OUT.PRINTLN (Key+ "\ T" +value); }//Body PartString Inputline; String Str= ""; Try { while((Inputline = Br.readline ())! =NULL) {str+=Inputline; } br.close (); } Catch(IOException e) {System.out.println ("IOException:" +e); } System.out.println ("STR:" +str); }
Java gets the header and body of the HTTP request