繁体   English   中英

如何在百里香中的字符串中传递参数

[英]How do I pass a parameter in a string in thymeleaf

我试图通过在百里香的href链接中传递任务ID来删除列表中的项目。 这就是它的样子

<a th:href="@{'delete-task?id='${task.id}}"> 

但不是删除项目,而是输出

delete-task?id=th:text=%27${task.id}%27

我在松弛跟踪中收到此错误

 : Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
Can anyone tell me the correct syntax

您应该对链接使用thymeleaf的标准URL语法 -以便可以正确对URL进行转义。 您的链接应如下所示:

<a th:href="@{delete-task(id=${task.id})}">

我相信您的href应该看起来像这样:

<a th:href="@{'delete-task?id=' + ${task.id}}"></a>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM