JSP 重定向/转发

发布于 2024-11-10 14:32:41 字数 594 浏览 6 评论 0 原文

我有这个页面:

http://example.com/folder/page.jsp

我想要如果出现错误/异常,则重定向/转发到页面 http://example.com/page.jsp (如您所见,路径不同)。

执行 确实有效,但所有 css 和 img 引用现在都会搜索 http://example.com/folder/csshttp:// example.com/folder/img ,不保留 example.com/page.jsp 布局。

我该如何解决这个问题?

I have this page:

http://example.com/folder/page.jsp

I would like to redirect/forward, in case of error/exception to the page http://example.com/page.jsp
(as you can see the path is different).

doing <jsp:forward page="/page.jsp"> does work but all css and img ref now searches for http://example.com/folder/css , http://example.com/folder/img , without keeping the example.com/page.jsp layout.

How can I fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗失的美好 2024-11-17 14:32:41

以绝对方式引用你的 css、javascript 和图像,如下所示:

<link rel="stylesheet" type="text/css" href="/css/my.css" />

Reference you css, javascript and images in a absolute way like this:

<link rel="stylesheet" type="text/css" href="/css/my.css" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文