直接上配置文件, 讨论群:172429747
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="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/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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- 启动扫描所有的controller -->
<context:component-scan base-package="com.inspur.web.ctrl">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
<!-- 支持注解 -->
<mvc:annotation-driven />
<!-- 静态资源不走springMVC 过滤器 -->
<mvc:resources location="/resources/css/**" mapping="/css/**" />
<mvc:resources location="/resources/js/**" mapping="/js/**" />
<mvc:resources location="/resources/html/**" mapping="/html/**" />
<mvc:resources location="/resources/images/**" mapping="/images/**" />
<mvc:resources location="/resources/swf/**" mapping="/swf/**" />
<!-- 拦截器 -->
<mvc:interceptors>
<bean class="com.inspur.util.spring3.interceptor.InspurInterceptor" />
</mvc:interceptors>
<!--通用视图解析器 -->
<bean id="viewResolverCommon"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.InternalResourceView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1" />
</bean>
<!-- 配置freeMarker视图解析器 -->
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<!-- <property name="viewClass" -->
<!-- value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" /> -->
<property name="viewClass"
value="com.inspur.util.freemarker.view.NativeFreemarkerView" />
<property name="exposeRequestAttributes" value="true" />
<property name="allowSessionOverride" value="true"/>
<property name="exposeSessionAttributes" value="true" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="contentType" value="text/html; charset=utf-8" />
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".ftl" />
<property name="order" value="0" />
</bean>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="ignoreAcceptHeader" value="true" />
<property name="defaultContentType" value="text/html" />
<property name="mediaTypes">
<map>
<entry key="json" value="application/json" />
</map>
</property>
<property name="favorParameter" value="false" />
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
</list>
</property>
<property name="defaultViews">
<list>
<bean
class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
</list>
</property>
</bean>
<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape" />
<!-- 配置freeMarker的模板路径 -->
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="freemarkerSettings" ref="freemarkerConfiguration" />
<property name="templateLoaderPaths">
<list>
<value>WEB-INF/ftl/</value>
<value>classpath:/templates/</value>
</list>
</property>
<property name="freemarkerVariables">
<map>
<entry key="xml_escape" value-ref="fmXmlEscape" />
</map>
</property>
<property name="preferFileSystemAccess" value="false" />
</bean>
<!--spring MVC 上传配置 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="11000000" />
</bean>
</beans>
分享到:
相关推荐
SpringMVC自定义多视图,多视图实现
Spring MVC--5.视图和视图解析器
springMVC 多视图配置(Jsp Freemarket Json)实例
理解视图和视图解析器的解析流程、使用常用的InternalResourceView和JstlView、实现自定义视图、实现重定向操作
SpringMVC及视图解析器
整合velocity和jsp 通过不同视图解析器,返回不同视图
在线投票系统-jsp+springMVC+mybatis在线投票系统-jsp+springMVC+mybatis在线投票系统-jsp+springMVC+mybatis在线投票...jsp+springMVC+mybatis在线投票系统-jsp+springMVC+mybatis在线投票系统-jsp+springMVC+mybatis
springmvc 3.1 多视图,freemarker jsp
springmvc+mybatis+ehcache+jsp+sitemesh完美运行
Spring+SpringMVC+Hibernate+JSP操作数据
springMVC spring mybatis rest风格架构 根据请求的后缀名 解析成json 或者 xml格式的数据
本篇文章主要介绍了浅谈SpringMVC之视图解析器(ViewResolver),具有一定的参考价值,有兴趣的可以了解一下
该项目主要技术架构包括:spring+springMVC+Mybatis+MYSQL+Redis+Maven,适合初学者,简单易懂。
SpringMVC+Hibernate+Spring+JSP整合实例_CSDN_2017
SpringMVC3+jsp
pringMVC +Mybatis 多个数据源配置 DEMO + maven,利用AbstractDataSource抽象化完成多了个数据源的配置
springboot+springMVC+tk.mybatis+lombook+yml配置+logback-spring日志配置+ueditor源码修改整合 经测试有效,内附数据库文件及测试账号数据,在项目/doc文件夹中
SpringMVC+运行流程解析,SpringMVC+运行流程解析,SpringMVC+运行流程解析
SSM(Spring+SpringMVC+MyBatis)多数据源配置框架,精简版
一、项目运行 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持) ...Springboot+ SpringMVC + JPA+ Jsp + Html+ JavaScript + JQuery + Ajax + maven等等