Java Spring VelocityViewResolver能否处理多种内容类型?

Java Spring VelocityViewResolver能否处理多种内容类型?,java,spring,spring-mvc,velocity,Java,Spring,Spring Mvc,Velocity,我正在REST Spring MVC应用程序中使用Spring的ContentNegotingViewResolver和VelocityViewResolver,该应用程序将支持多种不同的响应类型 我希望Velocity能够处理多种内容类型,但它似乎只支持1个默认文本/html或通过contentType属性提供。在下面的配置示例中,我希望Velocity支持html、csv和自定义内容类型 使用1个VelocityViewResolver是否可以实现这一点?还是需要为每种内容类型配置一个 &l

我正在REST Spring MVC应用程序中使用Spring的ContentNegotingViewResolver和VelocityViewResolver,该应用程序将支持多种不同的响应类型

我希望Velocity能够处理多种内容类型,但它似乎只支持1个默认文本/html或通过contentType属性提供。在下面的配置示例中,我希望Velocity支持html、csv和自定义内容类型

使用1个VelocityViewResolver是否可以实现这一点?还是需要为每种内容类型配置一个

<bean id="viewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
    <property name="mediaTypes">
        <map>
            <entry key="xml" value="application/xml"/> <!-- MarshallingView -->
            <entry key="json" value="application/json"/> <!-- MappingJacksonJsonView -->

            <!-- Would like the 3 content types below handled by Velocity -->
            <entry key="html" value="text/html"/>
            <entry key="csv" value="application/csv"/>
            <entry key="custom" value="application/custom"/>
        </map>
    </property>
    <property name="viewResolvers">
        <list>
            <bean class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
                <property name="cache" value="false"/>
                <property name="prefix" value=""/>
                <property name="suffix" value=".vm"/>
            </bean>
        </list>
    </property>
</bean>

我假设VelocityViewResolver正确处理html,但当ViewResolver确定内容类型为csv或自定义时会发生什么?它返回HTTP 406不可接受,因为定义的视图都不接受csv或自定义。我假设VelocityViewResolver正确处理html,但是当ViewResolver确定内容类型为csv或custom时会发生什么情况?它返回一个HTTP 406 not acceptable(不可接受),因为定义的视图都不接受csv或custom