Spring boot + thymeleaf 后端直接給onclick函數(shù)賦值的實現(xiàn)代碼
更新時間:2017年06月21日 17:11:56 作者:十年面壁
這篇文章主要介紹了Spring boot + thymeleaf 后端直接給onclick函數(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 == "認證成功") {
window.location.href = ("/admin/corp/list");
} else {
alert("認證失敗");
}
},
error: function (data) {
alert("認證失敗");
}
});
}
以上所述是小編給大家介紹的Spring boot + thymeleaf 后端直接給onclick函數(shù)賦值的實現(xiàn)代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章:
- spring為java.util.Properties類型的屬性進行賦值過程解析
- springboot~ObjectMapper~dto到entity的自動賦值
- Spring Boot使用Value注解給靜態(tài)變量賦值的方法
- Spring boot整合Mybatis實現(xiàn)級聯(lián)一對多CRUD操作的完整步驟
- Spring Data MongoDB中實現(xiàn)自定義級聯(lián)的方法詳解
- Spring MVC中Ajax實現(xiàn)二級聯(lián)動的簡單實例
- SpringBoot沒有主清單屬性的解決方法
- Spring Boot中的屬性綁定的實現(xiàn)
- spring級聯(lián)屬性賦值的兩種方式解析
相關(guān)文章
關(guān)于Sentinel中冷啟動限流原理WarmUpController
這篇文章主要介紹了關(guān)于Sentinel中冷啟動限流原理WarmUpController,具有很好的參考價值,希望對大家有所幫助。2023-04-04
Java實現(xiàn)“年-月-日 上午/下午時:分:秒”的簡單代碼
當前的日期輸出的方法有很多,本文為大家介紹下在java中是如何實現(xiàn)“年-月-日 上午/下午時:分:秒”,感興趣的朋友不妨參考下2015-08-08
使用eclipse導(dǎo)入javaWeb項目的圖文教程
這篇文章主要介紹了如何使用eclipse導(dǎo)入別人的javaWeb項目,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-07-07
java讀取excel圖片導(dǎo)入代碼示例(親測有效)
在日常工作中,我們經(jīng)常要將一些照片插入到Excel表格中,這篇文章主要給大家介紹了關(guān)于java讀取excel圖片導(dǎo)入的相關(guān)資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2023-10-10

