• @Restcontroller与@controller区别


    @RestController注解相当于@ResponseBody + @Controller合在一起的作用。

    1)如果只是使用@RestController注解Controller,则Controller中的方法无法返回jsp页面,配置的视图解析器InternalResourceViewResolver则不起作用,返回的内容就是Return 里的内容(String/JSON)。
    例如:本来应该到success.jsp页面的,则其显示success.

    2))如果使用@RestController注解Controller,需要返回到指定页面,则需要配置视图解析器InternalResourceViewResolver,可以利用ModelAndView返回试图。

    3)如果使用@Controller注解Controller,如果需要返回JSON,XML或自定义mediaType内容到页面,则需要在对应的方法上加上@ResponseBody注解。

  • 相关阅读:
    android SQLiteDatabase数据库使用的时候 常见问题
    ArrayList与LinkedList的基本添加删除方法 模拟栈 队列
    ImageView小技巧
    TextView 小技巧
    悬浮窗
    帧动画布局文件 animation-list
    VideoView的全屏问题
    FragmentPagerAdapter与FragmentStatePagerAdapter区别
    观察者模式 DataObserver
    vue中filter的用法
  • 原文地址:https://www.cnblogs.com/h-c-g/p/10406953.html
Copyright © 2020-2023  润新知