Reputation:
I have a controller like so,
@RequestMapping(value = "/sample")
public ResponseEntity<> search() throws Exception{
return new ResponseEntity("Hello World",OK);
}
This works fine, but when I dont use ResponseEntity for returning the result but return the String instead, it does not work,
@RequestMapping(value = "/sample")
public String search() throws Exception{
return "Hello Worls";
}
This does not work and I get a 404! Any help greatly appreciated
Upvotes: 1
Views: 784
Reputation: 24591
Use ReponseBody
annotation:
@RequestMapping(value = "/sample")
public @ResponseBody String search() throws Exception{
return "Hello Worls";
}
Upvotes: 2