url重写(urlRewrite)后的css,js等路径问题

今天在url重写后碰到页面布局混乱,即路径不对了:
为了不改动之前的代码太大,用了以下办法,在jsp文件里加上<base href="<%=basePath%>">
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<head>
		<base href="<%=basePath%>">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

你可能感兴趣的:(java,jsp,css)