I have developed a Spring MVC - Hibernate application as told here.
Now I am trying to modify this code to create a REST application as told here.
I have added Jackson
library to the classpath and added @XmlRootElement
.
@XmlRootElement(name = "persons")
public class Person implements Serializable {
But if I do a application/json
request then I still get the html
code back.
What I am doing wrong / forgot to do?
My controller:
@RequestMapping(value = "/persons", method = RequestMethod.GET)
@ResponseBody
public String getPersons(Model model) {
logger.info("Received request to show all persons");
// Retrieve all persons by delegating the call to PersonService
List<Person> persons = personService.getAll();
model.addAttribute("persons", persons);
return "personspage";
}
Changed the Controller, but get an error: t
ype Status report
message /Buddies/WEB-INF/jsp/main/persons/1.jsp
description The requested resource (/Buddies/WEB-INF/jsp/main/persons/1.jsp) is not available.