一、CommonCustomer.java
@Override
public String toString() {
JSONObject object=new JSONObject();
object.put("serialNo",serialNo);
object.put("customerId",customerId);
object.put("customerName",customerName);
object.put("alias",alias);
return object.toJSONString();
}
二、界面
<div class="col-sm-3">
<select id="customer" name="customer" class="form-control m-b">
<option>----请选择-----</option>
<option th:each="commonCustomer : ${commonCustomerList}" th:title="${commonCustomer}" th:text="${commonCustomer.customerName}" th:value="${commonCustomer.customerName}"></option>
</select>
</div>
三、js
$('#customer').on('select2:select', function (evt) {
var data=JSON.parse(evt.params.data.title);
$('#customerAlias').val(data.alias);
});
注:有问题改下这里试下<script th:inline="javascript">