thymeleaf org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing

22 篇文章 0 订阅
11 篇文章 0 订阅

springboot项目,前端用的thymeleaf,对象列表页点击跳转到对象编辑页的时候报了一个错

ERROR o.t.TemplateEngine - [process,1136] - [THYMELEAF][http-nio-9998-exec-3] Exception processing template "system/bmExpress/editGetExpress": An error happened during template parsing (template: "class path resource [templates/system/bmExpress/editGetExpress.html]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/system/bmExpress/editGetExpress.html]")

 原因是前端页面使用thymeleaf取值的时候没获取到值,看了下,是后端没有给ModelMap对象赋值导致的:

Controller

	/**
	 * 跳转到修改快递物流
	 */
	@GetMapping("/edit/{expressId}")
	public String edit(@PathVariable("expressId") Long expressId, ModelMap mmap)
	{
		BmExpress bmExpress = boomExpressService.selectBmExpressById(expressId);

		mmap.put("bmExpress", bmExpress);//注意,之前就是大意了,没写这行,导致前端读不到数据报错的
		if(bmExpress.getExpressType().equals(0)){
			return prefix + "/editGetExpress";
		}
		return prefix + "/editSendExpress";
	}

Html (注意,这里编辑的对象是bmExpress,对应Controller中ModelMap对象里的bmExpress)

<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-bmExpress-edit" th:object="${bmExpress}">
            <input id="expressId" name="expressId" th:field="*{expressId}"  type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">项目名:</label>
				<div class="col-sm-8">
					<input id="merchantOrderTitle" name="merchantOrderTitle" th:field="*{merchantOrderTitle}" class="form-control" type="text">
				</div>
			</div>
			<!-- 其他数据 -->
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		
	</script>
</body>
</html>

 

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值