添加两行代码即可
<% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";%> <!DOCTYPE html> <html> <head> <base href="<%=basePath%>">