Thymeleaf 首发教程 与 spring 整合
来源:互联网 发布:ubuntu 15.10 阿里源 编辑:程序博客网 时间:2024/05/18 15:54
上一节讲了Thymeleaf的基本介绍,这一节讲述怎么Thymeleaf 与 spring整合
Thymeleaf的jar自带了 与 Spring的整合的相关扩展包 ThymeleafViewResolver 视图
首先添加依赖
1
<
dependency
>
2
<
groupId
>org.thymeleaf</
groupId
>
3
<
artifactId
>thymeleaf</
artifactId
>
4
<
version
>2.0.18</
version
>
5
</
dependency
>
1
<
dependency
>
2
<
groupId
>org.thymeleaf</
groupId
>
3
<
artifactId
>thymeleaf-spring3</
artifactId
>
4
<
version
>2.0.18</
version
>
5
</
dependency
>
第二步 在spring mvc中加入下列
01
<!--声明视图 -->
02
<
bean
id
=
"templateResolver"
class
=
"org.thymeleaf.templateresolver.ServletContextTemplateResolver"
03
p:prefix
=
"/WEB-INF/templates/"
04
p:suffix
=
".html"
05
p:templateMode
=
"HTML5"
06
p:order
=
"1"
/>
07
08
<
bean
id
=
"templateEngine"
class
=
"org.thymeleaf.spring3.SpringTemplateEngine"
09
p:templateResolver-ref
=
"templateResolver"
/>
10
11
<
bean
class
=
"org.thymeleaf.spring3.view.ThymeleafViewResolver"
12
p:templateEngine-ref
=
"templateEngine"
/>
注意到这里 加了p xmlns命名空间 其实p命名空间相当于property 属性 ,同spring 配置基本视图一样 你也可以改成这种风格
1
<
bean
id
=
"viewResolver"
2
class
=
"org.springframework.web.servlet.view.InternalResourceViewResolver"
>
3
<
property
name
=
"viewClass"
4
value
=
"org.springframework.web.servlet.view.JstlView"
/>
5
6
<
property
name
=
"prefix"
value
=
"/WEB-INF/jsp/"
></
property
>
7
<
property
name
=
"suffix"
value
=
".jsp"
></
property
>
8
</
bean
>
下面就可以看上一篇文章 controller注入model 绑定,,,等等 进行开发了
比较忙,忙于找工作,apache wicket还没有更新,本打算今天更新一篇事件驱动spring integration 之消息中间件 RabbitMQ 又要拖明天了
0 0
- Thymeleaf 首发教程 与 spring 整合
- Thymeleaf 首发教程 与 spring 整合
- thymeleaf与spring整合
- Thymeleaf 首发教程
- springBoot thymeleaf与Spring整合
- spring boot 整合 thymeleaf
- Spring Boot整合thymeleaf
- SpringBoot与Thymeleaf整合
- thymeleaf模板使用笔记(与Spring整合)
- spring-boot--整合thymeleaf模板
- spring-boot--整合thymeleaf模板
- Spring Boot(4)整合thymeleaf
- Spring Boot 整合 Thymeleaf 完整 Web 案例
- Spring Boot 整合 Thymeleaf 完整 Web 案例
- Spring Boot整合Thymeleaf模板引擎
- Spring boot项目整合thymeleaf和shiro
- Spring Boot与Thymeleaf集成
- JQuery与Thymeleaf整合:[[${someObject.someValue}]]
- win32应用程序和win32控制台应用程序
- vim简单命令学习
- 理解本真的REST架构风格
- MySQL数据库操作基础
- linux 长目录快捷方式以及各个配置文件作用
- Thymeleaf 首发教程 与 spring 整合
- 彼此的眼神里就有了一份默契的笑意,你
- JS正则表达式验证数字,整数,email
- 彻底搞懂字符编码(unicode,mbcs,utf-8,utf-16,utf-32,big endian,little endian...)
- 赵雅智_java多线程下载
- 第14周 项目二 形状类族的中的纯虚函数
- OWASP Top 10 – 2013, 最新十大安全隐患(ASP.NET解决方法)
- Fibonacci数列的递归简单实现
- cocos2dx 精灵缓存学习