首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jersey POST 方法报错(MediaType出错),大家用过的知道是什么原因吗?该怎么处理

2012-02-02 
jerseyPOST方法报错(MediaType出错),大家用过的知道是什么原因吗?Java code@POST@Path(test_post4)@Cons

jersey POST 方法报错(MediaType出错),大家用过的知道是什么原因吗?

Java code
    @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;      }  

Java code
    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);      }


报错如下
Exception in thread "main" com.sun.jersey.api.client.UniformInterfaceException: POST http://localhost:8088/getstart/test_post4 returned a response status of 415 Unsupported Media Type
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:676)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:553)
at com.ibm.crl.iot.rest.spectrum.clientTest.main(clientTest.java:47)


[解决办法]
你说的和这人说的正相反呢http://blog.csdn.net/heihei0923/article/details/4791910
[解决办法]
这个报错信息写的很清楚了嘛

热点排行