Caused by: org.attoparser.ParseException:

复制代码
报错:
   Caused by: org.attoparser.ParseException: Only variable expressions returning numbers or booleans are allowed in this context, any other datatypes are not trusted in the context of this expression, including Strings or any other object that could be rendered as a text literal. A typical case is HTML attributes for event handlers (e.g. "onload"), in which textual data from variables should better be output to "data-*" attributes and then read from the event handler. (template: "fourteenth/cfgshareimage/list" - line 241, col 65)
    at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)
    at org.attoparser.MarkupParser.parse(MarkupParser.java:257)
    at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)
    ... 83 common frames omitted



修改前代码
复制代码
th:οnclick="getCopyUrl('shareImageUrl1${language.getKey}'“
复制代码
修改后的代码:


<button type="button" class="layui-btn" style="margin-top:30px;"
        th:id="'ID-upload-copy'+${language.getKey}" th:data-url="shareImageUrl1+${language.getKey}" th:οnclick="getCopyUrl(this.dataset.url)">

解释:

1. 通过 data-* 属性传递数据

Thymeleaf 认为在 onclick 等事件处理器中直接插入字符串可能会存在 XSS(跨站脚本攻击)风险,因此不允许将非数值或布尔类型直接用于事件属性。可以考虑将字符串数据存储在 data-* 属性中,然后通过 JavaScript 读取这个 data-* 属性值来动态构建 getCopyUrl()

相关推荐
小J听不清16 小时前
CSS 文本对齐方式实战:text-align 核心用法
前端·javascript·css·html·css3
我爱学习_zwj16 小时前
设计模式-2(单例模式与原型模式)
前端·javascript·设计模式
bugcome_com16 小时前
ASP.NET Web Pages 教程 —— Razor 语法全面指南
前端·asp.net
霍理迪16 小时前
Vue—侦听属性
前端·javascript·vue.js
酉鬼女又兒16 小时前
零基础入门前端弹性布局(Flexbox)实战:结合 Class 与 ID 选择器(可用于备赛蓝桥杯Web开发应用)
前端·css·蓝桥杯·html·html5
小J听不清16 小时前
CSS display 属性全解析:块级 / 行内 / 行内块 / 隐藏
前端·javascript·css·html·css3
早點睡39016 小时前
ReactNative项目Openharmony三方库集成实战:react-native-safe-area-context
javascript·react native·react.js
ONLYOFFICE16 小时前
ONLYOFFICE 全新 PDF 编辑器 API 上线,自动化处理 PDF 内容
前端·人工智能·pdf·编辑器·onlyoffice
James man16 小时前
前端节点连接库选型指南:React-Flow、AntV X6 与 Power-Link 深度对比
前端·react.js·前端框架
于慨16 小时前
java Web
java·开发语言·前端