這里是控制器里返回的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/** * @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è)面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<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> <button type= "button" th:onclick= "'javascript:check('+${corp.id}+',3)'" >拒絕 </button> </td> </tr> |
JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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ù)器之家網(wǎng)站的支持!
原文鏈接:http://blog.csdn.net/gongzhao426177/article/details/73550155