添加文件/webapp/WEB-INF/spring/webmvc-config.xml
文件内容
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="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"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="writeAcceptCharset" value="false" />
</bean>
<bean class="org.springframework.http.converter.ResourceHttpMessageConverter" />
<bean class="com.baifubao.superhero.service.rest.client.CustomAllEncompassingFormHttpMessageConverter">
<constructor-arg name="charset" value="GBK" />
</bean>
<bean class="com.baifubao.superhero.service.rest.client.CustomMappingJackson2HttpMessageConverter">
<constructor-arg name="charset" value="GBK" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<context:component-scan base-package="com.baifubao" use-default-filters="false">
<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>
<context:property-placeholder location="classpath:payfront-app-config.properties" order="1" ignore-unresolvable="true"/>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="com.baifubao.superhero.util.log.mdc.WebLogMdcHandlerInterceptor"/>
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.baifubao.superhero.service.rest.context.ServiceContextInterceptor"/>
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="com.baifubao.superhero.util.web.security.access.BnsAccessHandlerInterceptor">
<property name="enable" value="${payfront.tomcat.access.interceptor.enable}" />
</bean>
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**" />
<mvc:exclude-mapping path="/services/**" />
<bean class="com.baifubao.superhero.util.log.digest.web.WebDigestLogHandlerInterceptor" c:loggerName="PAGE-DIGEST-LOGGER" />
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/services/**" />
<bean class="com.baifubao.superhero.util.log.digest.web.WebDigestLogHandlerInterceptor" c:loggerName="SERVICE-DIGEST-LOGGER" />
</mvc:interceptor>
</mvc:interceptors>
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources -->
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>
<!-- Allows for mapping the DispatcherServlet to "/" by forwarding static resource
requests to the container's default Servlet -->
<mvc:default-servlet-handler/>
<!-- Resolves localized messages*.properties and application.properties files in the application to allow for internationalization.
The messages*.properties files translate Roo generated messages which are part of the admin interface, the
application.properties resource bundle localizes all application specific messages such as entity names and menu items. -->
<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application" p:fallbackToSystemLocale="false"/>
<!-- Enable this for integration of file upload functionality -->
<bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver" id="multipartResolver"/>
<!-- Velocity -->
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/view"/>
<property name="velocityProperties">
<props>
<prop key="input.encoding">GBK</prop>
<prop key="output.encoding">GBK</prop>
<prop key="contentType">text/html;charset=GBK</prop>
<prop key="file.resource.loader.cache">${velocity.file.resource.loader.cache}</prop>
<prop key="file.resource.loader.modificationCheckInterval">${velocity.file.resource.loader.modificationCheckInterval}</prop>
<prop key="velocimacro.library.autoreload">${velocity.velocimacro.library.autoreload}</prop>
<prop key="velocimacro.library">macro.vm</prop>
</props>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
<property name="suffix" value=".vm"/>
<property name="prefix" value="vm/" />
<property name="layoutUrl" value="layouts/default.vm" />
<property name="contentType" value="text/html;charset=GBK" />
<property name="cache" value="${velocity.view.resolver.cache}"/>
<property name="exposeSpringMacroHelpers" value="true"/>
<property name="exposeRequestAttributes" value="true"/>
<property name="exposeSessionAttributes" value="true"/>
<property name="requestContextAttribute" value="rc"/>
</bean>
</beans>
红色部分就是请求上下文的配置,配置到velocity上下文后,就可以在vm模版里面直接使用了:${rc.contextPath}
分享到:
相关推荐
这是我写的一个Spring + Spring MVC + MyBatis + Velocity + MySQL 框架搭建完整项目,里面包含了所需的全部JAR包已经相关源码,感兴趣的同学可以下载喽。。。 配合我的博客更好哦!
本篇文章将通过一个简单显示用户信息的实例整合Spring mvc+mybatis+Maven+velocity+mysql. 一、.Maven工程目录 二、Spring mvc + mybatis +maven实现 1.Mysql数据库表数据
Maven 整合 Spring mvc + Mybatis + Velocity 的实例
Maven + Spring mvc + Mybatis + Velocity 整合实例,之前上传的整合 Demo,修改了一些问题,所以重新上传了一个
Spring MVC+Maven+Velocity配置实例
maven+springMVC+mybatis+velocity+mysql+junit项目框架搭建
Maven + Spring mvc + Mybatis + Velocity +国际化配置 整合实例,之前上传的整合 Demo,修改了一些问题,所以重新上传了一个
maven+spring mvc+hibernate+dubbo+velocity+mysql的demo源码,运行前请修改resources/config.properties下的数据配置
Spring+SpringMVC+Mybatis+Velocity+Maven整合
spring+velocity+ibatis
spring mvc mybatis velocity 示范
struts + spring + hibernate + velocity + ajax + jotm + acegi
spring3 mvc mybatis velocity登录功能的简单实现,主要是想用下mybatis和velocity
SpringMVC3+velocity最简单配置例子,入门级的demo
NULL 博文链接:https://jjjssh.iteye.com/blog/2065902
struts2.2+velocity+tiles+spring3+mybatis3.05集成框架实例 ,最新的框架组合.。
spring+velocity发送邮件,spring+velocity发送邮件
spring+hibernate+velocity 架构的简单例子
spring mvc与velocity整合