<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<script type="text/javascript">
window.onload = function(){
window.parent.parent.location.href="<%=path%>/user/toLogin.action";
}
</script>
</html>
做jsp的时候,把这些访问路径取出来,可以方便在页面动态设置访问路径
<%
String path = request.getContextPath();
System.out.printf(path);//获取项目上下文路径 /PerFinSW
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
System.out.printf(request.getScheme());// 访问协议 http
System.out.printf(request.getServerName());//访问的项目地址 localhost
;//request.getSercerPort()获取访问端口 System.out.printf(basePath);//项目访问全路径 http://localhost:8080/PerFinSW/
%>