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

相关推荐
猿大师播放器35 分钟前
猿大师中间件:Chrome网页内嵌PhotoShop微信桌面应用程序
前端·chrome
excel37 分钟前
Node.js + TensorFlow.js(GPU 加速)完整安装指南(Windows 本地编译版)
前端·后端
小磊哥er37 分钟前
【办公自动化】如何使用Python操作PPT和自动化生成PPT?
前端
前端小巷子38 分钟前
深入理解 Vue Router
前端·vue.js·面试
未来之窗软件服务44 分钟前
企业收款统计:驱动业务决策的核心引擎设计开发——仙盟创梦IDE
javascript·css3·仙盟创梦ide·东方仙盟·企业收款码
月熊1 小时前
企业级WEB应用服务器TOMCAT
java·前端·tomcat
艾小码1 小时前
HTML5 & CSS3 从入门到精通:构建现代Web的艺术与科学
前端·css3·html5
yqcoder1 小时前
【无标题】
开发语言·javascript·ecmascript
袁煦丞2 小时前
OpenKylin 桌面系统,开源自由,跨界协作:cpolar内网穿透实验室第624个成功挑战
前端·程序员·远程工作
excel2 小时前
JavaScript 尾递归优化详解
前端