Jax RS not converting List to JSON instead throw an 500 status message
I'm converting my data through REST protocol with JAX RS. I have a lot of working functionality already but I can't seem to convert the following thing:
Function im calling
public List<Tweet> search(String input) {
ArrayList<Tweet> foundTweets = new ArrayList<Tweet>();
for(int i = 1; i <= this.tweets.size(); i++){
if(this.find(new Long(i)).getContent().contains(input)){
foundTweets.add(this.tweets.get(i));
}
}
return foundTweets;
}
This throws an 500 error status code
@POST
@Path("/search")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public List<Tweet> searchTweets(){
return tweetService.searchTweets("content"); // this contains 10 items in list
}
But this works for example
@POST
@Path("/getAll")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public List<Tweet> searchTweets(){
return tweetService.getAll(); // returns list of tweets
}
I'm quite confused right now. The search method is not available in my Tweet model. This might be one of the reasons? First time I work with JAX RS.
This line added Tweets but these tweets were all null. So I changed my code a bit and now everything works correctly.
foundTweets.add(this.tweets.get(i));
链接地址: http://www.djcxy.com/p/45630.html
上一篇: 如何通过AJAX发送外部表单POST数据