日期:2014-05-17 浏览次数:20921 次
@POST @Path("test_post4") @Consumes("application/x-www-form-urlencoded") @Produces("text/plain") public String getTest22222(InputStream is, @Context HttpServletRequest request) throws Exception{ byte[] buf = new byte[is.available()]; is.read(buf); System.out.println("buf:"+new String(buf)); String result; result= "--------"+request.getContextPath(); return result; }
public static void main(String[] args) throws URISyntaxException { // TODO Auto-generated method stub URI u = new URI("http://localhost:8088/getstart/test_post4"); System.out.println(u); Client client=Client.create();; WebResource resource = client.resource(u); String buf = "inputstream content."; ByteArrayInputStream bais = new ByteArrayInputStream(buf.getBytes()); String result = resource.entity(bais).post(String.class); System.out.println(result); }