thymeleaf th:onclike 傳入多個字符串

我是這麼寫的
 th:onclick="showImage([[${files.filePath}]],[[${files.thumbnailPath}]])"

兩個參數中間用英文逗號隔開javascript

可是我在網上看到,有人是這麼寫的java

th:οnclick="'javascript:searchHot(\''+${hot.name}+'\',\''+${hot.hotType}+'\')'"

我試了一下,報如下錯誤express

Caused by: org.thymeleaf.exceptions.TemplateProcessingException: 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: "system/knowledge/edit" - line 119, col 69)
    at org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression(VariableExpression.java:181)
    at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:66)
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:109)
    at org.thymeleaf.standard.expression.AdditionExpression.executeAddition(AdditionExpression.java:96)
    at org.thymeleaf.standard.expression.ComplexExpression.executeComplex(ComplexExpression.java:62)
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:112)
    at org.thymeleaf.standard.expression.AdditionExpression.executeAddition(AdditionExpression.java:89)
    at org.thymeleaf.standard.expression.ComplexExpression.executeComplex(ComplexExpression.java:62)
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:112)
    at org.thymeleaf.standard.expression.AdditionExpression.executeAddition(AdditionExpression.java:89)
    at org.thymeleaf.standard.expression.ComplexExpression.executeComplex(ComplexExpression.java:62)
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:112)
    at org.thymeleaf.standard.expression.AdditionExpression.executeAddition(AdditionExpression.java:89)
    at org.thymeleaf.standard.expression.ComplexExpression.executeComplex(ComplexExpression.java:62)
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:112)
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:138)
    at org.thymeleaf.standard.processor.StandardDOMEventAttributeTagProcessor.doProcess(StandardDOMEventAttributeTagProcessor.java:214)
    at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
    at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95)
    at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633)
    at org.thymeleaf.engine.ProcessorTemplateHandler.handleStandaloneElement(ProcessorTemplateHandler.java:918)
    at org.thymeleaf.engine.StandaloneElementTag.beHandled(StandaloneElementTag.java:228)
    at org.thymeleaf.engine.Model.process(Model.java:282)
    at org.thymeleaf.engine.Model.process(Model.java:290)
    at org.thymeleaf.engine.IteratedGatheringModelProcessable.processIterationModel(IteratedGatheringModelProcessable.java:367)
    at org.thymeleaf.engine.IteratedGatheringModelProcessable.process(IteratedGatheringModelProcessable.java:221)
    at org.thymeleaf.engine.ProcessorTemplateHandler.handleCloseElement(ProcessorTemplateHandler.java:1640)
    at org.thymeleaf.engine.TemplateHandlerAdapterMarkupHandler.handleCloseElementEnd(TemplateHandlerAdapterMarkupHandler.java:388)
    at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler$InlineMarkupAdapterPreProcessorHandler.handleCloseElementEnd(InlinedOutputExpressionMarkupHandler.java:322)
    at org.thymeleaf.standard.inline.OutputExpressionInlinePreProcessorHandler.handleCloseElementEnd(OutputExpressionInlinePreProcessorHandler.java:220)
    at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler.handleCloseElementEnd(InlinedOutputExpressionMarkupHandler.java:164)
    at org.attoparser.HtmlElement.handleCloseElementEnd(HtmlElement.java:169)
    at org.attoparser.HtmlMarkupHandler.handleCloseElementEnd(HtmlMarkupHandler.java:412)
    at org.attoparser.MarkupEventProcessorHandler.handleCloseElementEnd(MarkupEventProcessorHandler.java:473)
    at org.attoparser.ParsingElementMarkupUtil.parseCloseElement(ParsingElementMarkupUtil.java:201)
    at org.attoparser.MarkupParser.parseBuffer(MarkupParser.java:725)
    at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:301)
    ... 97 more

說是隻能穿布爾類型和數字類型,不知道沒試過app

相關文章
相關標籤/搜索