java中重定向得时候经常会遇到绝对路径和相对路径的问题,这里总结一下
工具/原料
java,电脑
方法/步骤
1
在jsp页面中发送请求时;直接写请求地址,他是相对与当前请求地址发送相对路径,就是最后/后面得数据改变;
2
请确保与手机号码准确,否则会影响后期奖品领取.
3
if(u!=null){ System.out.println('拦截器验证登录'); return true; } String local = request.getServerName()+':';//:获取服务器名,localhost; int dk = request.getServerPort();//:获取服务器端口号,8080; response.sendRedirect('dealer_login.do'); return false;拦截器中得重定向,也是相对于当前路径下得相对路径;
方法/步骤2
1
获取根路径
2
3
<% String path = request.getContextPath(); String basePath = request.getScheme() + '://' + request.getServerName() + ':' + request.getServerPort() + path + '/';%>
4 基本信息