<base href=""/> 的应用
以前页面有这样的
1
|
< a href="<%=path%>/manager/login_toLogin.do">我要去登录</ a > |
在页面里添加了<base/>标签
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<%@ page language= "java" import = "java.util.*" pageEncoding= "UTF-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+ "://" +request.getServerName()+ ":" +request.getServerPort()+path+ "/" ; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > <html> <head> <base href= "<%=basePath%>" /> <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" /> <title>登录管理平台</title> <link href= "dwz/themes/css/login.css" rel= "stylesheet" type= "text/css" /> </head> |
之后,代码可以写成这样
1
|
< a href = "manager/login_toLogin.do" >我要去登录</ a > |
特别是简化图片、css等路径的使用。好东西啊!