java restful风格服务报错:javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException
2016-12-09 16:19
1676 查看
java restful风格服务返回json 时 报错 :javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException:
java代码// 这里@Path定义了类的层次路径。 // 指定了资源类提供服务的URI路径。 @Path(value = "Account") public class Account { @POST // @POST表示方法会处理HTTP POST请求 @Path(value = "/login") // 这里@Path定义了子资源的层次路径。指定了资源类提供服务的URI路径。value可省略 ,即Path("login") @Consumes({ MediaType.APPLICATION_FORM_URLENCODED }) // @Consumes 注释代表的是一个资源可以接受的 MIME 类型。 @Produces(MediaType.APPLICATION_JSON) // @Produces 注释代表的是一个资源可以返回的 MIME 类型。 public Object login(String param) { try { System.out.println(URLDecoder.decode(param, "UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } UserInfo user = new UserInfo(); user.setUserName("测试123"); return user; } }
解决方法:
添加下面的jar文件
jackson-core-asl-1.8.5.jar jackson-jaxrs-1.8.5.jar jackson-mapper-asl-1.8.5.jar jackson-xc-1.8.5.jar
jar下载地址:http://cn.jarfire.org/jackson.xc.html
相关文章推荐
- Jersey&Rest异常:javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException
- 通过Jersey客户端API调用RestFul风格的Web服务
- 通过Jersey客户端API调用RestFul风格的Web服务
- 通过Jersey客户端API调用RestFul风格的Web服务
- Spring Cloud Jersey java.lang.NoSuchMethodError:javax.ws.rs.core.Application.getProperties()Ljava/ut
- Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jersey/api/client/config/ClientCo
- 通过Jersey客户端API调用RestFul风格的Web服务
- javax.xml.ws.WebServiceException: Provider com.sun.xml.ws.spi.ProviderImpl not found
- 坑了,comet4j 405 居然会受 com.sun.jersey 或者 javax.ws.rs 的影响 linux
- jax-rs(Java API for RESTful Web Services)实践教程 之二 —— get/post/put/delete/head
- 使用 Jersey 和 Apache Tomcat 构建 RESTful Web 服务---很详细,转自http://www.ibm.com/developerworks/cn/web/wa-aj-t
- java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.spi.WSResourceAdapterImpl
- jax-rs(Java API for RESTful Web Services) 实践教程 之四 —— @Context注入HttpServletRequest 使REST保持状态!
- jboss7 Java API for RESTful Web Services (JAX-RS) 官方文档
- RESTful Webservices with Java (Jersey / JAX-RS)
- 通过 Jersey 客户端 API 调用 REST 风格的 Web 服务
- java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application的解决办法
- 通过 Jersey 客户端 API 调用 REST 风格的 Web 服务
- 严重: Parse error in application web.xml file at jndi:/localhost/ipws/WEB-INF/web.xml java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml