base标签使用
Jsp页面常见代码:
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%><%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%>"> <title>My JSP 'test.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--> </head> <body> <%=request.getAttribute("yfddtjbData") %> <input type="button" value="打印" onclick="javascript:print();"/> </body></html>
<html> <head> <base href="http://www.baidu.com" target="_blank"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>base标记</title> <link rel="stylesheet" type="text/css" href="styles.css"></head> <body> <a href="1.htm" target="_self">测试链接1</a> <a href="2.htm">测试链接2</a> </body> </html>
http://www.baidu.com/1.htm //当前页打开http://www.baidu.com/2.htm //弹出页打开