1. Relative path
For relative files:
a.html page <link rel="stylesheet" href="font.css" type="text/css" />, font.css and a.html are in the same directory.
Relative to the server:
<link rel="stylesheet" href="/font.css" type="text/css" />, the address should start with "/".
Writing url in ajax: 'getUser'
2. Absolute path:
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
<base href="<%=basePath%>">
<link rel="stylesheet" href="font.css" type="text/css" />,相对于base。
ajax中写法 url:‘<%=basePath%>getUser’
。