0
JAX RS를 사용하여 REST 프로토콜을 통해 데이터를 변환하고 있습니다. 이미 작업 많은 기능을 가지고 있지만 나는 다음과 같은 일을 변환 할 수없는 것 :Jax RS가 JSON으로 목록을 변환하지 않고 대신 500 개의 상태 메시지를 내 보냅니다.
호출 기능 메신저
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;
}
이는 500 오류 상태 코드를 발생
@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
}
예를 들어 작동합니다.
@POST
@Path("/getAll")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public List<Tweet> searchTweets(){
return tweetService.getAll(); // returns list of tweets
}
저는 지금 당황 스럽습니다. 검색 방법은 내 Tweet 모델에서 사용할 수 없습니다. 이것은 이유 중 하나 일 수 있습니까? 처음 JAX RS에서 작업했습니다.