Spring boot + thymeleaf 后端直接給onclick函數(shù)賦值的實(shí)現(xiàn)代碼
這里是控制器里返回的
/** * @param pageUtil 分頁(yè)工具類 * @param cliCorpQuery 查詢類 * @param model model * @return String */ @RequestMapping(value = {"/list"}, method = RequestMethod.GET) public String list(PageUtil<CliCorp> pageUtil, CliCorpQuery cliCorpQuery, Model model) { PageUtil<CliCorp> corps; try { corps = corpClientService.queryByPage(pageUtil, cliCorpQuery); } catch (Exception e) { logger.error("queryByPage error:" + e.getMessage()); return "queryByPage error"; } model.addAttribute("corps", corps); return VIEW_PATH + "list"; }
頁(yè)面
<tr th:each="corp:${corps.contents}"> <td><span th:text="${corp.name}"></span></td> <td><span th:text="${corp.creditCode}"></span></td> <td><span th:text="${corp.taxNo}"></span></td> <td><span th:text="${corp.showName}"></span></td> <td><span th:text="${corp.bank}"></span></td> <td><span th:text="${corp.bankAccount}"></span></td> <td><span th:text="${corp.agent}"></span></td> <td><span th:text="${corp.address}"></span></td> <td><span th:text="${corp.status}"></span></td> <td><span th:text="${corp.creator}"></span></td> <td> <button type="button" th:onclick="'javascript:check('+${corp.id}+',2)'">審核 </button> <button type="button" th:onclick="'javascript:check('+${corp.id}+',3)'">拒絕 </button> </td> </tr>
JS
function check(id, status) { $.ajax({ type: "POST", data: {id: id, status: status}, url: "/admin/corp/check", success: function (data) { if (data == "認(rèn)證成功") { window.location.href = ("/admin/corp/list"); } else { alert("認(rèn)證失敗"); } }, error: function (data) { alert("認(rèn)證失敗"); } }); }
以上所述是小編給大家介紹的Spring boot + thymeleaf 后端直接給onclick函數(shù)賦值的實(shí)現(xiàn)代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- spring為java.util.Properties類型的屬性進(jìn)行賦值過程解析
- springboot~ObjectMapper~dto到entity的自動(dòng)賦值
- Spring Boot使用Value注解給靜態(tài)變量賦值的方法
- Spring boot整合Mybatis實(shí)現(xiàn)級(jí)聯(lián)一對(duì)多CRUD操作的完整步驟
- Spring Data MongoDB中實(shí)現(xiàn)自定義級(jí)聯(lián)的方法詳解
- Spring MVC中Ajax實(shí)現(xiàn)二級(jí)聯(lián)動(dòng)的簡(jiǎn)單實(shí)例
- SpringBoot沒有主清單屬性的解決方法
- Spring Boot中的屬性綁定的實(shí)現(xiàn)
- spring級(jí)聯(lián)屬性賦值的兩種方式解析
相關(guān)文章
Java?Swing實(shí)現(xiàn)畫板的簡(jiǎn)單操作
這篇文章主要介紹了Java?Swing實(shí)現(xiàn)畫板的簡(jiǎn)單操作,修改顏色,更改圖形,清除,任務(wù)欄按鈕,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06利用Spring插件實(shí)現(xiàn)策略模式的案例詳解
Spring插件提供了一種更實(shí)用的插件開發(fā)方法,它提供了插件實(shí)現(xiàn)擴(kuò)展核心系統(tǒng)功能的核心靈活性,但當(dāng)然不提供核心OSGi功能,如動(dòng)態(tài)類加載或運(yùn)行時(shí)安裝和部署插件,本文就來(lái)聊下如何使用spring插件來(lái)實(shí)現(xiàn)策略模式,需要的朋友可以參考下2023-05-05關(guān)于Sentinel中冷啟動(dòng)限流原理WarmUpController
這篇文章主要介紹了關(guān)于Sentinel中冷啟動(dòng)限流原理WarmUpController,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。2023-04-04Java實(shí)現(xiàn)“年-月-日 上午/下午時(shí):分:秒”的簡(jiǎn)單代碼
當(dāng)前的日期輸出的方法有很多,本文為大家介紹下在java中是如何實(shí)現(xiàn)“年-月-日 上午/下午時(shí):分:秒”,感興趣的朋友不妨參考下2015-08-08java使用UDP實(shí)現(xiàn)點(diǎn)對(duì)點(diǎn)通信
這篇文章主要為大家詳細(xì)介紹了java使用UDP實(shí)現(xiàn)點(diǎn)對(duì)點(diǎn)通信,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06使用eclipse導(dǎo)入javaWeb項(xiàng)目的圖文教程
這篇文章主要介紹了如何使用eclipse導(dǎo)入別人的javaWeb項(xiàng)目,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-07-07java讀取excel圖片導(dǎo)入代碼示例(親測(cè)有效)
在日常工作中,我們經(jīng)常要將一些照片插入到Excel表格中,這篇文章主要給大家介紹了關(guān)于java讀取excel圖片導(dǎo)入的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-10-10關(guān)于JVM默認(rèn)堆內(nèi)存大小問題
這篇文章主要介紹了關(guān)于JVM默認(rèn)堆內(nèi)存大小問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-02-02