html、jsp中很多地方不能用绝对路径;
像<IMG src="/img/login_logo.gif">
request.sendRedirect(/jsp/login.jsp);
等等
-----------------------------------------
即:
要转到/jsp/login.jsp如果是来源是/image.jsp
我就要request.sendRedirect(./jsp/login.jsp);如果是来源是/a/image.jsp
我就要request.sendRedirect(./../jsp/login.jsp);如果是来源是a/b/image.jsp
我就要request.sendRedirect(./../../jsp/login.jsp);请指教?
像<IMG src="/img/login_logo.gif">
request.sendRedirect(/jsp/login.jsp);
等等
-----------------------------------------
即:
要转到/jsp/login.jsp如果是来源是/image.jsp
我就要request.sendRedirect(./jsp/login.jsp);如果是来源是/a/image.jsp
我就要request.sendRedirect(./../jsp/login.jsp);如果是来源是a/b/image.jsp
我就要request.sendRedirect(./../../jsp/login.jsp);请指教?
解决方案 »
- Collections.sort(List<T> list) :为什么不同写法导致 顺序或逆序
- 关于applet的类载入告诉缓存的问题
- 同一页面有n个(n值不确定)同名的按钮,form怎么接收?
- java的数组是从零开始还是从壹开始的?
- 没有分数的呀@&@,看看jet做的本地可执行程序的效果
- 不知如何解决的错误提示
- 十萬火急!大家快幫忙!我在線上等待!!!
- 请问JAVA有没有真正的可变数组?不是指Vector谢谢
- 关于TreeSet集合框架无法添加自定义对象的问题.
- 本人Java菜鸟问几个关于图形化界面聊天软件的问题,望高手指点迷津!
- 写java程序时..怎么用相对路径啊?
- 帮忙解释一下“通过传值的方式传递引用”可以吗?
public java.lang.String getContextPath()Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string.
Returns:
a String specifying the portion of the request URI that indicates the context of the request
我就要request.sendRedirect(./jsp/login.jsp);如果是来源是/a/image.jsp
我就要request.sendRedirect(./../jsp/login.jsp);如果是来源是a/b/image.jsp
我就要request.sendRedirect(./../../jsp/login.jsp);
是对的