Servlet转发的网页CSS路径失效问题

这是因为在servlet中转发或者重定向时css的路径就是相对于这个servlet的相对路径而非jsp的路径了

使用绝对路径即可解决

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

猜你喜欢

转载自blog.csdn.net/Ein_Blatt/article/details/84382231