struts跳转jsp后没有样式

这个原因时通过struts.xml跳转页面时,部分引用的css,js等一些引用文件的路径找不到,自然就没有样式了,出现这个问题,直接将路径改为绝对路径就可以解决问题了。代码如下:

在jsp的顶部加上

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

如图:

然后引用就可以了

猜你喜欢

转载自blog.csdn.net/QQ17680473835/article/details/82181262
今日推荐