當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Thymeleaf中使用select进行消息回显时提示:Exception evaluaating SpringEL expression
生活随笔
收集整理的這篇文章主要介紹了
Thymeleaf中使用select进行消息回显时提示:Exception evaluaating SpringEL expression
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
場景
在進(jìn)行新增和編輯共用一個(gè)頁面時(shí),選擇新增則頁面沒有refundOrder傳值,
選擇編輯擇有。
使用thymeleaf進(jìn)行select的下拉選中的回顯時(shí)提示:
錯(cuò)誤代碼如下:
??
<select class="form-control" name="businessInitiator" ><option? id="qingjieInitiator" th:selected="${refundOrder.businessInitiator eq '清潔車間'}"? value="清潔車間" ><span th:text="清潔車間"></span></option><option? id="zhengjiInitiator" th:selected="${refundOrder.businessInitiator eq '正極車間'}"? value="正極車間" ><span th:text="正極車間"></span></option><option? id="fujiInitiator" th:selected="${refundOrder.businessInitiator eq '負(fù)極車間'}"? value="負(fù)極車間"><span th:text="負(fù)極車間"></span></option><option? id="xuanzeInitiator"th:selected="${refundOrder==null||refundOrder.businessInitiator==null}"? value="選擇退貨發(fā)起方"><span th:text="選擇退貨發(fā)起方"></span></option></select>實(shí)現(xiàn)
雖然提示是模板有問題,但是不是語法問題而是邏輯問題。
在新增頁面上refundOrder為空但是直接使用了其屬性作為條件判斷,沒有做非空判斷處理。
正確代碼:
<select class="form-control" name="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? == '負(fù)極車間'}" value="負(fù)極車間"><span th:text="負(fù)極車間"></span></option><option? id="xuanzeInitiator" th:selected="${refundOrder==null||refundOrder.businessInitiator==null}"? value="選擇退貨發(fā)起方"><span th:text="選擇退貨發(fā)起方"></span></option></select>?
總結(jié)
以上是生活随笔為你收集整理的Thymeleaf中使用select进行消息回显时提示:Exception evaluaating SpringEL expression的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: EasyUI中ToolTip提示框的简单
- 下一篇: select设置默认文字,不出现在下拉框