【发布时间】:2021-08-14 15:07:15
【问题描述】:
我想在 Spring+Thymeleaf Web 应用程序中创建并链接到外部站点并插入如下链接:<a th:href="@{https://example.com}">Link</a>
但是,通过点击链接,它会尝试指向内部位置 http://localhost/service/https://example.com,而不是外部网站 https://example.com。
网站只给出一个错误"status":500,"error":"Internal Server Error","message":"The request was rejected because the URL was not normalized."
出了什么问题以及如何与 Thymeleaf 建立绝对链接?
【问题讨论】:
-
为什么不直接使用
<a href="https://example.com">Link</a>或<a th:href="https://example.com">Link</a>? -
不是一个答案 - 只是一个观察:该语法是正确的。其他东西(过滤器?Spring?)可能正在重写 URL。就像测试一样,如果您硬编码 URL:
<a href="https://example.com">Link</a>,会发生什么?甚至<a th:href="@{'https://example.com'}">Link</a>? -
<a href="https://example.com">Link</a>也不起作用,它的作用完全相同。我正在尝试找出某些东西如何重写 URL 或如何禁用它
标签: java spring hyperlink thymeleaf