欢迎来到代码驿站!

JAVA代码

当前位置:首页 > 软件编程 > JAVA代码

Spring boot + thymeleaf 后端直接给onclick函数赋值的实现代码

时间:2021-11-13 15:29:40|栏目:JAVA代码|点击:

 这里是控制器里返回的 

  /** 
   * @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("认证失败"); 
     } 
   }); 
 } 

上一篇:一篇文章带你了解MySQL数据库基础

栏    目:JAVA代码

下一篇:Spring集成Druid连接池及监控配置的全过程

本文标题:Spring boot + thymeleaf 后端直接给onclick函数赋值的实现代码

本文地址:http://www.codeinn.net/misctech/183340.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有