Springboot 访问html页面

本文介绍了Springboot不推荐使用JSP的原因,并详细讲述了如何配置和使用Thymeleaf模板。在Springboot项目中,由于默认不支持JSP,需要额外配置。转向Thymeleaf时,添加相关依赖并创建Controller和HTML页面,注意Thymeleaf标签的使用以及后台数据传递的细节。通过实例展示了Thymeleaf模板的正确访问方式。
摘要由CSDN通过智能技术生成

1.看了网上很多文章,说是Springboot官方不推荐使用jsp,而推荐使用thymeleaf模版。(使用jsp需要在pom.xml中添加tomcat依赖,servlet依赖,还要修改application.yml/properties文件等等,否则访问会出现404)  搞了半天算是明白不推荐使用的意思,其实是默认不支持,需要手动下载jar包关联,修改配置等等。

2.thymeleaf模版:

既然使用jsp那么复杂,那么就想使用thymeleaf啦,看了网上的教程。首先在pom.xml中添加依赖:

<!-- 统一版本控制 -->
		<parent>
		
		<groupId>org.springframework.boot</groupId>
		
		<artifactId>spring-boot-starter-parent</artifactId>
		
		<version>1.4.0.RELEASE</version>
		
		<relativePath/> <!-- lookup parent from repository -->
		
		</parent>
		
	<dependencies>

		<!-- spring boot 核心 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
		    <groupId>junit</groupId>
	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值