I have a Spring MVC webapp that generates reports using JSP/JSTL. The client is now asking that I produce a link to PDF versions of the reports, which will have slightly different layout (eg. lose pagination, navigation etc).
In my servlet context I have:
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="pdf" value="application/pdf"/>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
</bean>
Which is taken from a tutorial somewhere. This seems to work as my old view resolver in that a GET with or without .html gets handled by my reportController (annotation request path mapping) and passed to the JSP and rendered correctly. The ReportController methods return a Strings that get resolved to JSPs.
Somehow I have to setup a PDF view that I can customise the layout of, perhaps using CSS or XSLT.
So right now a GET request to reports/basic/ or reports/basic.html will return the JSP rendering, I need to be able to do GET requests to fetch a PDF on URLs like reports/basic.pdf