Announcement Announcement Module
Collapse
No announcement yet.
Problem with XsltViewResolver Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
      <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:list>
            <beans:value>net.mortenoh.spring.domain.DataSet</beans:value>
            <beans:value>net.mortenoh.spring.domain.DataSetsRoot</beans:value>
          </beans:list>
        </beans:property>
      </beans:bean>
    
      <beans:bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <beans:property name="order" value="100" />
    
        <beans:property name="mediaTypes">
          <beans:map>
            <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/vnd.ms-excel" />
          </beans:map>
        </beans:property>
    
        <beans:property name="defaultViews">
          <beans:list>
            <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:bean>
          </beans:list>
        </beans:property>
    
        <beans:property name="viewResolvers">
          <beans:list>
    
            <beans:bean id="pdfViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
              <beans:property name="location" value="/WEB-INF/spring/pdf-views.xml" />
            </beans:bean>
    
            <beans:bean id="xlsViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
              <beans:property name="location" value="/WEB-INF/spring/xls-views.xml" />
            </beans:bean>
    
            <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:bean>
          </beans:list>
        </beans:property>
        <beans:property name="defaultContentType" value="text/html" />
      </beans:bean>
    </beans:beans>
    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?

    Regards,
    Morten
Working...
X