我决定搬到Jersey 2.5,我面临Java Beans转换到的某些问题JSON.我有一个UserBean,从一个服务我试图返回一个列表users.
我的服务代码获取用户列表:
@GET
@Path("getAllUsers")
@Produces(MediaType.APPLICATION_JSON)
public List<User> getAllUsers() {
//Fetching users list here
return users;
}
Run Code Online (Sandbox Code Playgroud)
我得到以下服务器控制台的例外:
[org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List<com.example.User>.] with root cause
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List<com.example.User>.
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149)
at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:103)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149)
at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:88)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1139)
at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:574)
at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:381)
at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:371)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:262)
Run Code Online (Sandbox Code Playgroud)
我错过了任何依赖项或任何2.5特定配置吗?
如果我指定了以下jQuery选择器:
$("div#myDivId .myClass")
确切的选择顺序是什么?这将首先选择一个带有ID的div,myDivId然后在其中找到所有元素,myClass或者首先选择所有元素,myClass然后过滤掉不在里面的其余元素myDivId.