Spring boot + thymeleaf 后端直接給onclick函數(shù)賦值的實(shí)現(xiàn)代碼
這里是控制器里返回的
/**
* @param pageUtil 分頁工具類
* @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";
}
頁面
<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)代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- spring為java.util.Properties類型的屬性進(jìn)行賦值過程解析
- springboot~ObjectMapper~dto到entity的自動賦值
- Spring Boot使用Value注解給靜態(tài)變量賦值的方法
- Spring boot整合Mybatis實(shí)現(xiàn)級聯(lián)一對多CRUD操作的完整步驟
- Spring Data MongoDB中實(shí)現(xiàn)自定義級聯(lián)的方法詳解
- Spring MVC中Ajax實(shí)現(xiàn)二級聯(lián)動的簡單實(shí)例
- SpringBoot沒有主清單屬性的解決方法
- Spring Boot中的屬性綁定的實(shí)現(xiàn)
- spring級聯(lián)屬性賦值的兩種方式解析
相關(guān)文章
通過實(shí)例講解springboot整合WebSocket
這篇文章主要介紹了通過實(shí)例講解springboot整合WebSocket,WebSocket為游覽器和服務(wù)器提供了雙工異步通信的功能,即游覽器可以向服務(wù)器發(fā)送消息,服務(wù)器也可以向游覽器發(fā)送消息。,需要的朋友可以參考下2019-06-06
springboot整合Dubbo與Feign的實(shí)現(xiàn)?(無注冊中心)
本文主要介紹了springboot整合Dubbo與Feign的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-04-04
SpringBoot集成shiro,MyRealm中無法@Autowired注入Service的問題
今天小編就為大家分享一篇關(guān)于SpringBoot集成shiro,MyRealm中無法@Autowired注入Service的問題,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2019-03-03
java實(shí)現(xiàn)字符串轉(zhuǎn)String數(shù)組的方法示例
這篇文章主要介紹了java實(shí)現(xiàn)字符串轉(zhuǎn)String數(shù)組的方法,涉及java字符串的遍歷、分割、轉(zhuǎn)換等相關(guān)操作技巧,需要的朋友可以參考下2017-10-10
spring-AOP 及 AOP獲取request各項(xiàng)參數(shù)操作
這篇文章主要介紹了spring-AOP 及 AOP獲取request各項(xiàng)參數(shù)的操作,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07
Java 實(shí)現(xiàn)多線程切換等待喚醒交替打印奇偶數(shù)
這篇文章主要介紹了Java 實(shí)現(xiàn)多線程切換等待喚醒交替打印奇偶數(shù) ,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-05-05

