java学习简单笔记201903045

spring boot的web开发,页面官方推荐使用thymeleaf模板,是一个java类库,一个xml/html/html5的板板引擎,可作为mvc的View视图层,提供了spring mvc集成,可完全替代jsp。

在thymeleaf中,要引入web项目下的static静态资源文件,可用<img th:src="@{js/xxxx.js}"方式 ,在需要动态处理的内容 前使用th:为前缀。

在html页面中要访问Model的数据,可使用<span th:text="${person.name}"访问,使用<li th:each="${listperson}"循环,${not #lists.isEmpty(personlist)}判断是否空值。

在thymeleaf中使用${}访问对象,@{}引入静态资源,#list相当于类;

html模板文件一般放在we项目的src/main/resources/templetes下,/static,/public,/resources,/meta-inf/resources文件夹下的静 态文件都会映身为/**,可直接访问。

application.properties配置文件中,通过 用的对servlet配置是以server开关,如server.port=xxxx,若是要对内嵌的tomcat配置,使用server.tomcat.xxxx=进行配置。

要使用其他Servlet容器,如Jetty,Undertom,可在pom.xml中把spring-boot-starter-tomcat中的tomcat名称替换成spring-boot-starter-jetty即可。

原文地址:https://www.cnblogs.com/lofe/p/10474643.html