Believe it or not, JavaServer Pages has been the go-to view technology for Java-based
web applications for almost 15 years. Although it started out as an ugly, Java-centric
twist on similar templating technologies (such as Microsoft’s Active Server Pages), JSP
has evolved over the years to include support for an expression language and custom
tag libraries.
Spring supports JSP views in two ways:
InternalResourceViewResolver can be used to resolve view names into JSP
files. Moreover, if you’re using JavaServer Pages Standard Tag Library (JSTL)
tags in your JSP pages, InternalResourceViewResolver can resolve view names
into JSP files fronted by JstlView to expose JSTL locale and resource bundle
variables to JSTL’s formatting and message tags.
Spring provides two JSP tag libraries, one for form-to-model binding and one
providing general utility features.
Whether or not you use JSTL or intend to use Spring’s JSP tag libraries, it’s important
to configure a view resolver to resolve JSP views. Although a few of Spring’s other view
resolvers could be used to map view names to JSP files, InternalResourceViewResolver is the simplest and most commonly used view resolver for this task. We
touched on configuring InternalResourceViewResolver in chapter 5. But that was
done in haste just so you could exercise your controllers in a web browser. Let’s take a
closer look at InternalResourceViewResolver and see how to tweak it to do your
bidding.
web applications for almost 15 years. Although it started out as an ugly, Java-centric
twist on similar templating technologies (such as Microsoft’s Active Server Pages), JSP
has evolved over the years to include support for an expression language and custom
tag libraries.
Spring supports JSP views in two ways:
InternalResourceViewResolver can be used to resolve view names into JSP
files. Moreover, if you’re using JavaServer Pages Standard Tag Library (JSTL)
tags in your JSP pages, InternalResourceViewResolver can resolve view names
into JSP files fronted by JstlView to expose JSTL locale and resource bundle
variables to JSTL’s formatting and message tags.
Spring provides two JSP tag libraries, one for form-to-model binding and one
providing general utility features.
Whether or not you use JSTL or intend to use Spring’s JSP tag libraries, it’s important
to configure a view resolver to resolve JSP views. Although a few of Spring’s other view
resolvers could be used to map view names to JSP files, InternalResourceViewResolver is the simplest and most commonly used view resolver for this task. We
touched on configuring InternalResourceViewResolver in chapter 5. But that was
done in haste just so you could exercise your controllers in a web browser. Let’s take a
closer look at InternalResourceViewResolver and see how to tweak it to do your
bidding.