Spring集成Velocity

最近对Velocity感兴趣,简单测试了一下,还有很多细节不明白。先把初步成果写在这。

1.springmvc的配置文件
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<mvc:annotation-driven/>

<!--使spring自动搜寻test包下用@Component注解的类-->
<context:component-scan base-package="test"/>

<!--viewResolver常见的配置,具体怎么回事,在控制器类说明-->

<!--必须有,否则报错 -->
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/velocity/"/>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="cache" value="true"/>
<property name="suffix" value=".vm"/>
</bean>
</beans>


猜你喜欢

转载自notafreak.iteye.com/blog/1881491