SpringMvc多视图整合配置教程(jsp、velocity、freemarker)
来源:互联网 发布:淘宝商品设置多个选项 编辑:程序博客网 时间:2024/05/16 09:54
SpringMvc多视图整合配置教程(jsp、velocity、freemarker)
说明一下目录结构
Spring配置文件
01
<?xml version=
"1.0"
encoding=
"UTF-8"
?>
02
<beans xmlns=
"http://www.springframework.org/schema/beans"
03
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
04
xmlns:p=
"http://www.springframework.org/schema/p"
05
xmlns:context=
"http://www.springframework.org/schema/context"
06
xsi:schemaLocation="
07
http:
//www.springframework.org/schema/beans
08
http:
//www.springframework.org/schema/beans/spring-beans-3.0.xsd
09
http:
//www.springframework.org/schema/context
10
http:
//www.springframework.org/schema/context/spring-context-3.0.xsd">
11
<context:component-scan
12
base-
package
=
"com.spring.action"
/>
13
<!--
14
org.springframework.web.servlet.view.ResourceBundleViewResolver
15
用于多个视图集成时,ResourceBundleViewResolver是通过解析资源文件来解析请求输出文件的。
16
<property name=
"basename"
value=
"views"
></property>,即表示在/WEB-INF/classes路径下有一个
17
views.properties文件,本例中views.properties的内容为
18
welcome.(
class
)=org.springframework.web.servlet.view.velocity.VelocityView
19
welcome.url=welcome.vm
20
freemarker.(
class
)=org.springframework.web.servlet.view.freemarker.FreeMarkerView
21
freemarker.url=freemarker.ftl
22
-->
23
<bean
class
=
"org.springframework.web.servlet.view.ResourceBundleViewResolver"
>
24
<property name=
"basename"
value=
"views"
></property>
25
<!--
26
<property name=
"order"
value=
"0"
></property>
27
-->
28
</bean>
29
30
<!-- jsp视图解析器 -->
31
<bean id=
"jspViewResolver"
class
=
"org.springframework.web.servlet.view.InternalResourceViewResolver"
>
32
<property name=
"viewClass"
value=
"org.springframework.web.servlet.view.JstlView"
/>
33
<property name=
"prefix"
value=
"/"
/>
34
<property name=
"suffix"
value=
".jsp"
/>
35
</bean>
36
37
<!-- velocity视图解析器 -->
38
<bean id=
"velocityViewResolver"
class
=
"org.springframework.web.servlet.view.velocity.VelocityViewResolver"
>
39
<property name=
"cache"
value=
"true"
/>
40
<property name=
"prefix"
value=
"/"
/>
41
<property name=
"suffix"
value=
".vm"
/>
42
</bean>
43
44
<!-- velocity环境配置 -->
45
<bean id=
"velocityConfig"
class
=
"org.springframework.web.servlet.view.velocity.VelocityConfigurer"
>
46
<!-- velocity配置文件路径 -->
47
<property name=
"configLocation"
value=
"/WEB-INF/velocity.properties"
/>
48
<!-- velocity模板路径 -->
49
<property name=
"resourceLoaderPath"
value=
"/WEB-INF/velocity/"
/>
50
</bean>
51
52
<!-- FreeMarker环境配置 -->
53
<bean id=
"freemarkerConfig"
class
=
"org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"
>
54
<!-- freemarker模板位置 -->
55
<property name=
"templateLoaderPath"
value=
"/WEB-INF/freemarker/"
/>
56
</bean>
57
58
<!-- FreeMarker视图解析 -->
59
<bean id=
"freeMarkerViewResolver"
class
=
"org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"
>
60
<property name=
"cache"
value=
"true"
/>
61
<property name=
"prefix"
value=
"/"
/>
62
<property name=
"suffix"
value=
".ftl"
/>
63
</bean>
64
</beans>
views.properties
1
#welcome为modelAndView.setViewName(
" welcome "
) ; 中的welcome .(
class
)固定写法
2
welcome.(
class
)=org.springframework.web.servlet.view.velocity.VelocityView
3
#welcome.url 路径 welcome.vm模板名称
4
welcome.url=welcome.vm
5
6
#freemarker为modelAndView.setViewName(
" freemarker "
) ; 中的freemarker .(
class
)固定写法
7
freemarker.(
class
)=org.springframework.web.servlet.view.freemarker.FreeMarkerView
8
#freemarker.url 路径 freemarker.ftl模板名称
9
freemarker.url= freemarker.ftl
点我下载示例代码
原文:http://www.blogjava.net/sxyx2008/archive/2011/07/13/354280.html
0 0
- SpringMvc多视图整合配置教程(jsp、velocity、freemarker)
- SpringMvc多视图整合配置教程(jsp、velocity、freemarker)
- SpringMvc多视图整合配置教程(jsp、velocity、freemarker)
- springMVC多视图整合配置教程(jsp,velocity,freemarker)
- SpringMvc多视图整合配置教程(jsp、velocity、freemarker)
- SpringMvc多视图整合配置教程(jsp、velocity、freemarker)
- springmvc集成 velocity,实现多视图整合(jsp,velocity)
- Spring MVC多视图整合(jsp、velocity、freemarker)
- Spring mvc 配置多视图 jsp freemarker velocity等
- Spring MVC多视图配置(jsp, freemarker, Velocity)
- SpringMVC 配置多视图解析器(velocity,jsp)
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- SpringMVC配置多视图JSP+freemarker,实践成功!
- springmvc 配置多视图(jsp,freemarker,HTML等)
- springmvc 配置多视图(jsp,freemarker,HTML等)
- springmvc 配置多视图(jsp,freemarker,HTML等)
- 网站攻击的三种手段及预防方法
- 学习篇--log4j.properties
- JavaScript之解释与执行
- codeforce 550c Divisibility by Eight (DFS)
- BlocksKit初见:一个支持将delegate转换成block的Cocoa库
- SpringMvc多视图整合配置教程(jsp、velocity、freemarker)
- 浅谈json转c#对象
- JavaScript基础(2):什么是“闭包”?
- win10+ubuntu14.04双系统有线网络问题
- 软件测试会大概问的一些问题整理续
- Linux 下 NFS服务的搭建
- javascript动态获取当前页面的url
- 分享:EditText默认不弹出软件键盘
- React Native Android Navigator的使用