问题描述
最近在做一个项目,使用到了springmvc刚开始学,不知道具体配置意思。需求是想能够返回jsp视图,excel视图,以及json格式的字符串。配置文件如下。<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"><context:component-scanbase-package="com.isoft.controller"><context:include-filtertype="annotation"expression="org.springframework.stereotype.Controller"/><context:exclude-filtertype="annotation"expression="org.springframework.stereotype.Service"/><context:exclude-filtertype="annotation"expression="org.springframework.stereotype.Repository"/></context:component-scan><mvc:annotation-driven><mvc:message-converters><beanclass="org.springframework.http.converter.StringHttpMessageConverter"><propertyname="supportedMediaTypes"><list><value>application/json;charset=UTF-8</value></list></property></bean></mvc:message-converters></mvc:annotation-driven><beanclass="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"><propertyname="mediaTypes"><map><entrykey="xml"value="application/xml;charset=utf-8"/><entrykey="html"value="text/html;charset=utf-8"/><entrykey="json"value="application/json;charset=utf-8"/><entrykey="xsl"value="application/vnd.ms-excel"/></map></property><propertyname="viewResolvers"><list><beanclass="org.springframework.web.servlet.view.BeanNameViewResolver"/><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><propertyname="viewClass"value="org.springframework.web.servlet.view.JstlView"></property><propertyname="prefix"value="/WEB-INF/jsp/"/><propertyname="suffix"value=".jsp"/></bean></list></property><propertyname="defaultViews"><list><beanclass="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/><beanclass="com.isoft.view.ExcelReportView"/></list></property></bean></beans>在chrome浏览器可以正常匹配到jsp视图和返回json格式字符串,但是导出excel不能导出。而在ie6浏览器就全部报错,不能匹配到jsp页面。求大神赐教。