某个方法,返回字符串
@Controller
public class HelloController {
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return "hello world quick";
}
}
所有方法返回字符串
@ResponseBody
@Controller
public class HelloController {
@RequestMapping("/hello")
public String hello(){
return "hello world quick";
}
}
将@Controller和@ResponseBody合体为@RestController
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello(){
return "hello world quick";
}
}