From c44c35bf2ac61a6ddb478804a57c9b91abe631dd Mon Sep 17 00:00:00 2001 From: chenxing Date: Sat, 19 Sep 2026 17:18:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(portal):=20=E9=94=99=E8=AF=AF=E9=A1=B5?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E9=A6=96=E9=A1=B5=E9=93=BE=E6=8E=A5=E6=94=B9?= =?UTF-8?q?=20th:href=3D@{/portal/}=20=E6=84=9F=E7=9F=A5=20context-path?= =?UTF-8?q?=EF=BC=88R-04=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/error/400.html | 4 ++-- src/main/resources/templates/error/404.html | 4 ++-- src/main/resources/templates/error/500.html | 4 ++-- src/main/resources/templates/error/error.html | 4 ++-- src/test/java/com/yunhai/cms/portal/PortalErrorPageIT.java | 4 ++++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/resources/templates/error/400.html b/src/main/resources/templates/error/400.html index 3c7e32b..a9bf23d 100644 --- a/src/main/resources/templates/error/400.html +++ b/src/main/resources/templates/error/400.html @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@
400

请求参数有误

页面地址中的参数不正确(如页码格式错误)。
请修正后重试,或返回门户首页继续浏览。

- 返回门户首页 + 返回门户首页 diff --git a/src/main/resources/templates/error/404.html b/src/main/resources/templates/error/404.html index 83ad770..d25234c 100644 --- a/src/main/resources/templates/error/404.html +++ b/src/main/resources/templates/error/404.html @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@
404

页面不存在或已下线

您访问的页面可能已被删除、更改地址或暂时不可用。
请检查网址是否正确,或返回门户首页继续浏览。

- 返回门户首页 + 返回门户首页 diff --git a/src/main/resources/templates/error/500.html b/src/main/resources/templates/error/500.html index e2f6d75..ca5b598 100644 --- a/src/main/resources/templates/error/500.html +++ b/src/main/resources/templates/error/500.html @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@
500

服务暂时不可用

系统开小差了,工程师正在抢修。
请稍后刷新重试,或返回门户首页继续浏览。

- 返回门户首页 + 返回门户首页 diff --git a/src/main/resources/templates/error/error.html b/src/main/resources/templates/error/error.html index 976119f..6aeafb0 100644 --- a/src/main/resources/templates/error/error.html +++ b/src/main/resources/templates/error/error.html @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@
:(

出错了

请求处理出现异常,请稍后重试。
如持续出现,请联系管理员。

- 返回门户首页 + 返回门户首页 diff --git a/src/test/java/com/yunhai/cms/portal/PortalErrorPageIT.java b/src/test/java/com/yunhai/cms/portal/PortalErrorPageIT.java index 21d2794..3f401ea 100644 --- a/src/test/java/com/yunhai/cms/portal/PortalErrorPageIT.java +++ b/src/test/java/com/yunhai/cms/portal/PortalErrorPageIT.java @@ -60,6 +60,10 @@ class PortalErrorPageIT extends CmsIntegrationTestBase { assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(resp.getBody()).contains("页面不存在"); assertThat(resp.getBody()).doesNotContain("\"status\":404"); + // R-04:返回首页链接必须上下文感知(th:href="@{/portal/}"),不得硬编码 /cms 前缀 + // (本测试无 context-path → 渲染为 /portal/;部署在 /cms 下则自动带 /cms) + assertThat(resp.getBody()).contains("href=\"/portal/\""); + assertThat(resp.getBody()).doesNotContain("/cms/portal/"); assertThat(MediaType.parseMediaType(resp.getHeaders().getContentType().toString()) .includes(MediaType.TEXT_HTML)).isTrue(); }