Saturday 15 September 2012

java - 500 error after Controller return statement -


I am using spring as my MVC framework, and one of my controllers gives me 500 errors. However, I have debug this error and found that since the controller return statement 500 error has been thrown, so no error has been thrown to the server side. I am returning a map where the object is a custom class. I Jackson is imported correctly, and this custom class has a toString method (not sure that it is necessary). In addition, this same style of controller return works for other methods. I am unsure why 500 error is thrown. The code snippet is down thanks!

  @RequestMapping (value = "/ method", method = RequestMethod.GET) @ ResponseBodyBody public map & lt; String, Object & gt; Method () {Hashmap < String, Object & gt; RetMap = new hashmap & lt; & Gt; (); Result result = service.method (); RetMap.put ("Results", Results); Return RetMap; }  

So I have discovered this problem in my project Was defined, which was imported through Maven. Apparently Jackson does not pick up classes from other imported projects, so I created a DTO class in my web project and changed it to DTO before returning to the controller. Now it works perfectly!

EDIT: Does anyone know how to go to Jackson to scan sections with imported projects?


No comments:

Post a Comment