[Wise] -JSP role of school in the base href

Get the current path of the project, such as: HTTP: // localhost: 8080 / name /.
Set base path, basePath variable, simple static web pages, then you set the example:

<base href="http://www.jingyingjidi.com">

Then you will be following the href attribute to your set above as a benchmark, such as:

<a href="http://www.jingyingjidi.com/xxx.htm"></a>

Now you only need to write

<a href="xxx.htm"></a>

Example scenarios:

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath%>">
	<meta charset="UTF-8">
	<title>网站内容管理</title>
	......
``<base href="value">为页面上所有相对 URL 规定基准 URL:

Guess you like

Origin blog.csdn.net/weixin_39593940/article/details/90904999