博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
thymeleaf 的hello world
阅读量:6915 次
发布时间:2019-06-27

本文共 1724 字,大约阅读时间需要 5 分钟。

在研究一个模板引擎,选了这个thymeleaf 。中间遇到很多的问题。现在在这里记录一下。

第一步:导入jar包。这里使用maven导入jar包

org.thymeleaf
thymeleaf
2.1.5.RELEASE
org.thymeleaf
thymeleaf-spring4
2.1.5.RELEASE
org.thymeleaf.extras
thymeleaf-extras-springsecurity3
2.1.2.RELEASE

第二步:spring-mvc-servlet.xml 中加入thymeleaf解析。

text/html;charset=UTF-8

  这里注意了,templateMode 一定要设置为HTML5 ,不然会出问题。

第三步:控制器的方法

@RequestMapping(path="/thymeleaftest", method = RequestMethod.GET)    public String thymeleaftest(Model model){                System.out.println("thymeleaftest is start");        model.addAttribute("name", "你好,page name ====== thymeleaftest");                return "thymeleaftest";    }

第四步:页面thymeleaftest.html

      
hello world hello world

 然后访问,这里的访问和普通的springmvc的地址访问有点区别,thymeleaftest 是action名 + html ,而不是直接就是html名。

http://localhost:8080/myblog/thymeleaftest.html

就能够看到页面的效果了。

 

转载地址:http://srxcl.baihongyu.com/

你可能感兴趣的文章
以修改字体为例谈Android的listView开发优化
查看>>
addLoadEvent(func) 不管在页面加载完毕执行多少个函数,都应付自如
查看>>
Android下横竖屏切换的处理
查看>>
进击的JAVA(1)
查看>>
PHP整理笔记五目录与文件
查看>>
在ASP.net中使用OWC绘制统计图表
查看>>
【BZOJ 2440】[中山市选2011]完全平方数
查看>>
SVN学习总结(1)——SVN简介及入门使用
查看>>
嵌入式linux开发uboot移植(三)——uboot启动过程源码分析
查看>>
zabbix-agentd 的配置
查看>>
网站原创文章撰写的5点注意要素
查看>>
Linux 配置Apache服务器 下(虚拟主机,排错)
查看>>
我的友情链接
查看>>
ppp链路的pap认证与chap认证的基本原理和配置
查看>>
[Java] 练习题004: 将一个正整数分解质因数
查看>>
速战速决---3小时快速搭建Exchange+SFB(2)
查看>>
关于VCPROJ文件的说明
查看>>
我的友情链接
查看>>
在主引导记录(MBR)的救援模式下如何重新安装GRUB引导装载程序
查看>>
我的友情链接
查看>>