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

相关推荐
博客zhu虎康13 分钟前
React+Ant design
javascript·react.js·ecmascript
一只小阿乐4 小时前
react 封装弹框组件 传递数据
前端·javascript·react.js
533_5 小时前
[element-plus] el-tree 动态增加节点,删除节点
前端·javascript·vue.js
禁止摆烂_才浅5 小时前
前端开发小技巧-【JavaScript】- 获取元素距离 document 顶部的距离
前端·javascript·react.js
wshzd5 小时前
LLM之Agent(二十九)|LangChain 1.0核心组件介绍
前端·javascript·langchain
程序猿_极客5 小时前
Vue 2脚手架从入门到实战核心知识点全解析(day6):从工程结构到高级通信(附代码讲解)
前端·javascript·vue.js·vue2学习笔记
q***71855 小时前
海康威视摄像头ISUP(原EHOME协议) 摄像头实时预览springboot 版本java实现,并可以在浏览器vue前端播放(附带源码)
java·前端·spring boot
一只小阿乐5 小时前
vue3 使用v-model开发弹窗组件
javascript·vue.js·elementui
web加加5 小时前
vue3 +vite项目页面防f12,防打开控制台
前端·javascript·vue.js
A尘埃6 小时前
大模型应用python+Java后端+Vue前端的整合
java·前端·python