what different between InternalResourceViewResolver vs UrlBasedViewResolver

前端 未结 3 1184
小蘑菇
小蘑菇 2021-01-31 18:32

I just started using Spring. I came across a lot tutorials. I saw more examples using InternalResourceViewResolver than UrlBasedViewResolver. I looked

3条回答
  •  無奈伤痛
    2021-01-31 18:39

    Spring supports a wide range of view technologies. ViewResolvers are here to plug any of the known supported view technologies into your application.

    UrlBasedViewResolver is a simple view resolver which simply resolves views of different technologies, by matching URL patterns to corresponding file names.

    UrlBasedViewResolver is here to support all the view technologies of type "AbstractUrlBasedView".

    AbstractJasperReportsView, AbstractPdfStamperView, AbstractTemplateView, InternalResourceView, RedirectView, TilesView, XsltView are the known subclasses of AbstractUrlBasedView.

    So when you are using UrlBasedViewResolver you can use any one of the subclasses of AbstractUrlBasedView as the type of your view technology (by setting the corresponding viewClass only).

    InternalResourceViewResolver is a subclass of UrlBasedViewResolver.

    But when you are using InternalResourceViewResolver, (which is a convenient subclass of UrlBasedViewResolver), you can only use the technology of type InternalResourceView as your view technology.

    I think this answers your question.

提交回复
热议问题