spring boot + thymeleaf 后端直接给onclick函数赋值

这里是控制器里返回的
    /**
     * @param pageUtil     分页工具类
     * @param cliCorpQuery 查询类
     * @param model        model
     * @return String
     */
    @RequestMapping(value = {"/list"}, method = RequestMethod.GET)
    public String list(PageUtil pageUtil, CliCorpQuery cliCorpQuery, Model model) {
        PageUtil 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";
    }


页面

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


你可能感兴趣的:(web前端)