niuniutry

<!-- *************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

分类:

技术点:

相关文章:

  • 2021-10-06
  • 2021-08-12
  • 2021-10-16
  • 2021-05-23
  • 2021-12-08
  • 2021-09-29
  • 2021-08-07
  • 2021-12-03
猜你喜欢
  • 2022-01-17
  • 2021-12-20
  • 2022-02-08
  • 2022-01-23
  • 2022-01-05
  • 2021-12-06
  • 2021-08-02
相关资源
相似解决方案