Spring MVC整合Velocity
来源:互联网 发布:淘宝查gsx会泄露信息吗 编辑:程序博客网 时间:2024/05/16 11:56
velocity学习参考:http://www.ibm.com/developerworks/cn/java/j-lo-velocity1/
Spring MVC整合Velocity,就要引入相关的包,需要导入的包如下图
然后,就是进行很简单的配置了,那在这里,就修改下springMvc-servlet.xml内容,内容修改如下
- <?xml version="1.0" encoding="UTF-8"?>
- <!--看到下面的beans这个元素标签没有,必须有标签的声明 -->
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- 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.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd">
- <!-- 对web包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能 -->
- <context:component-scan base-package="qust.thb.*" />
- <!-- 支持spring3.0新的mvc注解 -->
- <mvc:annotation-driven />
- <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
- <!-- ViewResolver -->
- <!--
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
- <property name="prefix" value="/WEB-INF/" />
- <property name="suffix" value=".jsp" />
- </bean>
- -->
- <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
- <property name="resourceLoaderPath" value="/WEB-INF/"/>
- <property name="configLocation" value="/WEB-INF/velocity.properties"/>
- </bean>
- <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
- <property name="cache" value="true"/>
- <property name="prefix" value=""/>
- <property name="suffix" value=".vm"/>
- </bean>
- </beans>
input.encoding=UTF-8
output.encoding=UTF-8
然后,将view文件夹下的hello.jsp删除掉,新建一个文件,名为hello.vm,里面内容也很简单,如下
- <div>
- ${message}
- </div>
整体的目录结构如下图所示
输入地址http://localhost:8080/SpringMVC/user/getUser.do,访问正常访问
用到velocity,肯定要用到SiteMesh进行修饰,使得我们在由大量页面工程的项目中创建一致的页面布局和外观,如一致的导航条、一致的banner、一致的版权等。
下一篇介绍Spring MVC利用SiteMesh修饰velocity
http://blog.csdn.net/qust008/article/details/9625179
0 0
- Spring MVC 整合Velocity
- spring mvc 整合 velocity
- spring mvc整合velocity
- Spring MVC整合Velocity
- Spring MVC整合Velocity
- Spring MVC整合Velocity
- Spring MVC 与 Velocity 整合
- spring mvc+velocity整合开发
- 2、Spring MVC整合Velocity
- Spring MVC整合Velocity详解
- 3、spring mvc sitemesh velocity整合
- spring mvc整合velocity源码分析
- Maven 工程整合 Spring mvc + Mybatis +Velocity
- Spring MVC 整合Velocity及用法说明
- Spring MVC 整合Velocity及用法说明
- 续spring mvc+velocity之spring mvc + freemarker整合开发
- Spring MVC多视图整合(jsp、velocity、freemarker)
- Spring MVC+Mybatis+Maven+Velocity+Mysql整合实例
- ORA-01084: OCI 调用中的参数无效
- Assertion failure in -[UICollectionView layoutSublayersOfLayer:]
- POJ 2686 Traveling by Stagecoach (状态压缩DP)
- Beyond Compare是什么
- JavaScript学习记录
- Spring MVC整合Velocity
- 我一条腿跨进了linux大门
- 单例模式
- Java中关于Double 类型的数据比较
- iOS 视图高斯模糊(毛玻璃)效果实现
- 使用jdbc操作sql server数据库
- Android基础 | 控件基础 | Listview之SimpleAdapter
- BESAppServer中JavaDump分析
- jQuery可调整表和列宽插件-colResizable