将重定向发送到 JSP 中的相对路径? [英] Send redirect to relative path in JSP?

查看:27
本文介绍了将重定向发送到 JSP 中的相对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

response.sendRedirect("../seja/izpisknjig.jsp");

我在其中执行这一行的文件是 index.jsp.目录结构如下所示.
项目
--index.jsp
世佳
--izpisknjig.jsp

the file in which I execute this line is index.jsp. the directory structure looks like this.
project
--index.jsp
seja
--izpisknjig.jsp

如何形成重定向到izpisknjig.jsp的相对路径.

How do I form the relative path to redirect to izpisknjig.jsp.

推荐答案

最可靠的是创建一个包含上下文路径的域相关 URL.

Most reliable would be to create a domain-relative URL with the context path included.

response.sendRedirect(request.getContextPath() + "/seja/izpisknjig.jsp");

这篇关于将重定向发送到 JSP 中的相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆