我有一个像这样的控制器,
@RequestMapping(value = "/sample")
public ResponseEntity<> search() throws Exception{
return new ResponseEntity("Hello World",OK);
}
这很好用,但是当我不使用ResponseEntity返回结果但返回String时,它不起作用,
@RequestMapping(value = "/sample")
public String search() throws Exception{
return "Hello Worls";
}
这不起作用,我得到了404!任何帮助非常感谢
答案 0 :(得分:2)
使用ReponseBody
注释:
@RequestMapping(value = "/sample")
public @ResponseBody String search() throws Exception{
return "Hello Worls";
}