<!--多视图解析器--> <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <!--启用参数进行格式识别 xxx?format=json/html--> <property name="favorParameter" value="true"/> <!--启用后缀进行格式识别 xxx.json xxx.html--> <property name="favorPathExtension" value="true"/> <!--默认返回的类型--> <property name="defaultContentType" value="application/json"/> <property name="mediaTypes"> <value> json:application/json html=text/html </value> </property> </bean> <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <!--引入视图内容管理器--> <property name="contentNegotiationManager" ref="contentNegotiationManager"/> <property name="defaultViews" > <list> <bean class="com.alibaba.fastjson.support.spring.FastJsonJsonView"> <property name="fastJsonConfig"> <bean class="com.alibaba.fastjson.support.config.FastJsonConfig" > <property name="charset" value="UTF-8"/> <property name="dateFormat" value="yyyy-MM-dd HH:mm:ss"/> </bean> </property> </bean> </list> </property> <property name="viewResolvers"> <list> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/view/"></property> <property name="suffix" value=".jsp"></property> </bean> </list> </property> </bean>
多视图解析器
最新推荐文章于 2024-07-29 11:32:06 发布