Announcement Announcement Module
No announcement yet.
Problem with XsltViewResolver Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with XsltViewResolver

    Hi guys

    I'm trying to figure out whats going on with XsltViewResolver.. it keeps giving me weird error messages.

    So, this is my spring config
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns:xsi="" xmlns:beans=""
      xmlns:context="" xmlns:mvc=""
      <mvc:annotation-driven />
      <mvc:resources mapping="/resources/**" location="/resources/" />
      <context:component-scan base-package="net.mortenoh.spring" />
      <beans:bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <beans:property name="classesToBeBound">
      <beans:bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <beans:property name="order" value="100" />
        <beans:property name="mediaTypes">
            <beans:entry key="html" value="text/html" />
            <beans:entry key="json" value="application/json" />
            <beans:entry key="xml" value="application/xml" />
            <beans:entry key="pdf" value="application/pdf" />
            <beans:entry key="xls" value="application/" />
        <beans:property name="defaultViews">
            <beans:bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
            <beans:bean class="org.springframework.web.servlet.view.xml.MarshallingView">
              <beans:constructor-arg ref="jaxb2Marshaller" />
        <beans:property name="viewResolvers">
            <beans:bean id="pdfViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
              <beans:property name="location" value="/WEB-INF/spring/pdf-views.xml" />
            <beans:bean id="xlsViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
              <beans:property name="location" value="/WEB-INF/spring/xls-views.xml" />
            <beans:bean id="xsltViewResolver" class="org.springframework.web.servlet.view.xslt.XsltViewResolver">
              <beans:property name="viewClass" value="org.springframework.web.servlet.view.xslt.XsltView" />
              <beans:property name="prefix" value="/WEB-INF/xsl/" />
              <beans:property name="suffix" value=".xsl" />
              <beans:property name="order" value="200" />
        <beans:property name="defaultContentType" value="text/html" />
    And it sort of works.. but:

    1. I have a file in WEB-INF/xsl called dataSets.xsl, and my controller returns dataSets, so everything should be good, but no.. even if that file is there, it will try and look for dataSets.{xml,json,pdf,html, etc}.xsl.. and will give an error if it cant open those, if have ALL of those.. it will actually go back to dataSets.xsl and use this.. whats going on there? any suggestions?

    2. When it fallbacks on dataSets.xsl, it will render.. but it will return text/xml even if the incoming request was text/html, what can I do about this? When I was using AbstractXslView I had no trouble with this.. actually I had no trouble with anything.. but its deprecated, and XsltViewResolver seems very under documented..

    Any ideas?