springboot - web项目
Posted 小平1993
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot - web项目相关的知识,希望对你有一定的参考价值。
一:使用Thymeleaf:参考http://blog.csdn.net/u012702547/article/details/53784992#t0
1.1 引入相应的包
1.2 thymeleaf配置
1)配置类方式

@ConfigurationProperties("spring.thymeleaf") public class ThymeleafProperties { private static final Charset DEFAULT_ENCODING = Charset.forName("UTF-8"); private static final MimeType DEFAULT_CONTENT_TYPE = MimeType.valueOf("text/html"); public static final String DEFAULT_PREFIX = "classpath:/templates/"; public static final String DEFAULT_SUFFIX = ".html"; private boolean checkTemplate = true; private boolean checkTemplateLocation = true; private String prefix = "classpath:/templates/"; private String suffix = ".html"; private String mode = "HTML5"; ...... ...... ...... }
2)配置文件
application.properties文件中以spring.thymeleaf为前缀来配置相关属性
1.3 tomcat配置
server.port=8081#配置服务器端口,默认为8080 server.session-timeout=1000000#用户回话session过期时间,以秒为单位 server.context-path=/index#配置访问路径,默认为/ server.tomcat.uri-encoding=UTF-8#配置Tomcat编码,默认为UTF-8 server.tomcat.compression=on#Tomcat是否开启压缩,默认为关闭
1.2 工作原理
后台通过将javaBean或者其他java对象放入Model对象中,前台页面就可以通过${javaBean.name}来获得值,同时还有很多方法可以使用
以上是关于springboot - web项目的主要内容,如果未能解决你的问题,请参考以下文章
SpringBoot启动报错“Consider defining a bean of type ‘xxx.mapper.UserMapper‘ in your configuration.“(代码片段
maven web项目的web.xml报错The markup in the document following the root element must be well-formed.(代码片段
项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde(代码片段