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()。

相关推荐
Flynt8 小时前
AI 写的 Three.js 大屏,为什么越跑越卡?我在 Node 里复现了它的内存曲线
前端·ai编程·three.js
一个游离的指针10 小时前
Vue2:vue-router
前端·javascript·vue.js
凌晨三点说晚安13 小时前
理解 JavaScript 对象、原型与包装类
javascript
火山引擎和TA的超级拍档们13 小时前
产品情报局 11 | AI 数据湖 LAS:打造大模型时代多模态数据底座
前端·后端
JavaGuide13 小时前
Gemini 真的变强了,写代码做视频的能力接近 Claude Opus5.5 了!
前端·ai编程
凌晨三点说晚安13 小时前
理解 JavaScript 作用域链、return 与闭包
javascript
niceyayale13 小时前
WebRTC 延迟怎么调试:从 ICE 到 jitter buffer 的六个观测点
前端
aleimu13 小时前
Windows 11 右键打开 Cmder 2.0:从找不到菜单到默认使用 Cmder
前端·人工智能·后端
tryCbest13 小时前
Vue系列——第 20 篇:Vue Router 4——路由管理完全指南(上)
前端·javascript·vue.js
feixing_fx13 小时前
原始类型与引用类型:赋值时到底复制了什么
开发语言·前端·javascript·前端框架