Map<String, Object> saveInfoMap;
前端
$(function () {
var saveInfoMap = /*[[${saveInfoMap}]]*/null;
if (saveInfoMap != null) {
if (saveInfoMap.status === true) {
$("#error_info").text("保存成功!");
} else {
$("#error_info").text(saveInfoMap.message);
}
}
});
List<EhsResultDetail> ehsResultDetailList;
前端:
先在页面遍历数组,然后再在js中操作数组
<select multiple="multiple" id="seizureTypeSelect" style="display: none;">
<option th:each="seizure : ${ehsResultDetailList}"
th:value="${seizure.getChkRemarkCode()}"
th:text="${seizure.getChkRemarkCode() + ' ' + seizure.getChkRemarkName()}">
</option>
</select>
//遍历后台存在的查获项数组,展示匹配的查获项
var seizureTypeValue = $("#seizureTypeValue").val();
if (seizureTypeValue !== "") {
var seizureTypeInputVal = "";
var seizureTypeArr = seizureTypeValue.split(",");
var seizureTypeSelect = $("#seizureTypeSelect").find("option");
$.each(seizureTypeArr, function (i, val) {
$.each(seizureTypeSelect, function (index, value) {
if (val === $(value).val()) {
seizureTypeInputVal = seizureTypeInputVal+ $(value).text() + ",";
}
});
});
seizureTypeInputVal = seizureTypeInputVal.substring(0,seizureTypeInputVal.length-1);
$("#seizureType").val(seizureTypeInputVal)
}