使用SpringBoot+Thyemleaf 遇到的问题

使用Thymeleaf 模板时Controller 层要使用@Controller注解,使用RestController注解不会返回html页面

要在application.properties配置文件里面添加Thyemleaf 配置

#返回页面的路径
spring.thymeleaf.prefix=classpath:/templates/
#文件后缀
spring.thymeleaf.suffix=.html
#模式
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.servlet.content-type=text/html
#编码格式
spring.thymeleaf.encoding=utf-8
#不需要缓存
spring.thymeleaf.cache=false
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**

select 默认选中选择下拉框

<form id="save_info_form" method="post" role="form" class="form-horizontal" th:object="${subAreaItem}"
	<select id="subAreaItemType" onchange="changeSelect()" th:field="*{type}" class="form-control" readonly="readonly">
     	<option value="1" th:selected="*{type} eq '1'">观察类</option>
     	<option value="2" th:selected="*{type} eq '2'">抄表类</option>
     	<option value="3" th:selected="*{type} eq '3'">测量类</option>
	</select>
</form>

报错An error happened during template parsing

我自己遇到这个报错的原因是因为Thyemleaf 模板中使用的数据后台没有传过来,我在sql中添加了查询的字段就解决了

持续更新中…

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值