美文网首页
Spring Boot MVC api返回的String无法关联

Spring Boot MVC api返回的String无法关联

作者: 神之试炼者 | 来源:发表于2018-03-14 15:30 被阅读192次

    之前没搞明白@RestController和@Controller的区别.....所以用了@RestController, 导致跳不到视图.
    两者的区别如下:

    • @Controlleris used to mark classes as Spring MVC Controller.
    • @RestController is a convenience annotation that does nothing more than adding the @Controller and @ResponseBody annotations

    也就是: @RestController 等价于 @Controller 加上 @ResponseBody.
    @ResponseBody 表示该方法的返回不会被解析为跳转, 而是直接写入http响应正文

    原文: https://stackoverflow.com/questions/25242321/difference-between-spring-controller-and-restcontroller-annotation
    @ResponseBody参考文档: http://blog.csdn.net/ff906317011/article/details/78552426

    相关文章

      网友评论

          本文标题:Spring Boot MVC api返回的String无法关联

          本文链接:https://www.haomeiwen.com/subject/ysmfqftx.html