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

相关推荐
回眸&啤酒鸭43 分钟前
【回眸】OpenSwarm 多智能体协作系统实战指南
大数据·前端·人工智能
用户69371750013841 小时前
2026,程序员的时代拐点到了
android·前端·后端
大龄秃头程序员1 小时前
一次 iBeacon + BLE 无感解锁方案的实现记录
前端
小兔子1 小时前
Python 的 GIL 与 free-threading:3.13 之后「去 GIL」走到哪一步了
前端
IT_陈寒1 小时前
SpringBoot自动配置差点让我加班到凌晨
前端·人工智能·后端
guslegend2 小时前
脚手架原理与本地调试:从 bin 软链接到 npm link
前端·npm·node.js·脚手架·前端工程化
小宋10212 小时前
A2UI从零实战:Agent安全生成交互界面与事件回传
javascript·人工智能·安全·交互
大包子3 小时前
structuredClone vs lodash.cloneDeep:核心差异与选型指南
javascript·vue.js
海码事务所3 小时前
Google Play 新个人开发者账号上架指南:12 人连续 14 天封闭测试怎么做?
前端
田威AI3 小时前
图片内文字翻译的规格:输入输出、保真、自动化、时间与费用
前端·计算机视觉