【发布时间】:2018-06-06 09:51:52
【问题描述】:
我有一个通过 JavaScript 创建的 HTML 元素。 我在同一个 html 元素中输入了 Thymeleaf 对象。这是我的 js 代码:-
$("#subcategoryNameDiv").append(''+
'<div class="form-group margindate">'+
'<label class="control-label col-sm-3 datesubscription nowrap">Category Name:</label>'+
'<div class="col-sm-9 ">'+
'<select id="categorySelect" th:field="${category}" class="date_dropdown date_input form-control" onchange="loadSubcategories()">'+
'</select>'+
'</div>'+
'</div>'+
'<div class="form-group margindate" >'+
'<label class="control-label col-sm-3 datesubscription nowrap">Subcategory Name:</label>'+
'<div class="col-sm-9 ">'+
'<select id="subcategorySelect" th:field="*{subcategory}" class="date_dropdown date_input form-control" required>'+
'</select>'+
'</div>'+
'</div>');
Thymeleaf is working properly while creating normal HTML element and sending Object to Controller but as per our Project's requirement this element is being generated when a specific option is Selected.
注意 - 在这里,loadSubcategories() 函数正常工作并将值附加到 HTML 元素 id="subcategorySelect"。但是在 Spring Boot Controller 上提交“类别”和“子类别”值之后为空。
【问题讨论】:
标签: javascript java html spring-boot thymeleaf