<!– *************JSP代码******************–> 
<%@ page language=”java” pageEncoding=”GBK” contentType=”text/html;charset=gbk” isELIgnored=”false”%> 
<% 
String path = request.getContextPath(); 
// 获得项目完全路径(假设你的项目叫MyApp,那么获得到的地址就是 http://localhost:8080/MyApp/): 
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”; 
%> 
<html> 
<head> 
<!– base需要放到head中 –> 
<base href=” <%=basePath%>”> 
</head> 
// 这里我们就可以直接使用相对路径(即: 相对于base标签) 
<a href=”jsp/login.jsp”>Login </a> 
</html> 
<!– *************************************–>

 

另参考:http://blog.sina.com.cn/s/blog_03c54d100100wo6n.html

版权声明:本文为niuniutry原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/niuniutry/p/3399572.html