2013-07-30 58 views
0

您好我正在尝试使用REST Json编写小应用程序。我有一些方法返回实体对象的ArrayList。而我做的是:JSON + Spring 3.1

@RequestMapping(value="/workers/", method = RequestMethod.GET) 
public @ResponseBody ArrayList<Workers> showAllEmployes() throws Exception 
{ 
    ArrayList<Workers> workers = new ArrayList<Workers>(); 
    workers = (ArrayList<Workers>) spiroService.getAllWorkers(); 
    return workers; 
} 

并在此之后我:

HTTP Status 500. The server encountered an internal error that prevented it from fulfilling this request. 

当我尝试返回原始数据类型则一切正常。我在服务器日志中什么都没有。我有必要的进口。请点小费。

+1

您是否在服务器日志/控制台中获得带有更详细错误消息的Stacktrace? – micha

+0

请发布Workers类以及! –

+0

你的依赖/ classpath上有杰克逊jar吗? –

回答

0

似乎你在制作json格式时遇到问题,试试这个。

@RequestMapping(value = "/workers/", method = RequestMethod.GET, 
       produces={MediaType.APPLICATION_JSON_VALUE})