@restcontroller和@controller的区别
@restcontroller相当于@controller+@ResponseBody
@Controller //Controller
@RequestMapping("user")
public class UserController {
@RequestMapping("hello")
@ResponseBody //ResponseBody 返回的是数据,不加ResponseBody返回的是地址
public String hello(){
return "hello springbootMaping";
}
}
上面代码等价于
@RestController //@restcontroller等价于@Controller+@ResponseBody
@RequestMapping("user")
public class UserController {
@RequestMapping("hello")
public String hello(){
return "hello springbootMaping";
}
}