Thymelaf中使用select进行消息的回显
生活随笔
收集整理的這篇文章主要介紹了
Thymelaf中使用select进行消息的回显
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
場景
在進行新增和編輯時,如果后臺有傳遞到前端值,則根據值的內容選中下拉框。
實現
<select class="form-control" name="businessInitiator"? id="businessInitiator"><option? id="yuanliaoInitiator" th:selected="${refundOrder != null && refundOrder.businessInitiator != null && refundOrder.businessInitiator? == '原料立庫'}" value="原料立庫"><span th:text="原料立庫"></span></option><option? id="qingjieInitiator" th:selected="${refundOrder != null && refundOrder.businessInitiator != null && refundOrder.businessInitiator? == '清潔車間'}" value="清潔車間"><span th:text="清潔車間"></span></option><option? id="zhengjiInitiator" th:selected="${refundOrder != null && refundOrder.businessInitiator != null && refundOrder.businessInitiator? == '正極車間'}" value="正極車間"><span th:text="正極車間"></span></option><option? id="fujiInitiator" th:selected="${refundOrder != null && refundOrder.businessInitiator != null && refundOrder.businessInitiator? == '負極車間'}" value="負極車間"><span th:text="負極車間"></span></option><option value="" disabled selected hidden>選擇退貨發起方</option></select>后臺返回數據代碼:
@Description("獲取新增或者編輯界面")@RequestMapping("/toAddRefundOrder")public String toAddRefundOrder( int id, Model model){if ( id != 0){//如果是編輯操作,查詢出當前退貨單WmsRefundOrder refundOrder = refundOrderService.getById(id);model.addAttribute("refundOrder",refundOrder);}return "refund/addRefundOrder.html";}?
總結
以上是生活随笔為你收集整理的Thymelaf中使用select进行消息的回显的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: select设置默认文字,不出现在下拉框
- 下一篇: Jquery中绑定select的chan