Jsp页面放在WebContent中。文件放在WebContent\img中。我试着使用这样的风格:
background-image: url(img/background.jpg);它不起作用。但是,如果将JSP页面放在WebContent\WEB-INF中,它就可以工作。
我也试过了:
background-image: url(../img/background.jpg);
background-image: url(/img/background.jpg);更新:
当另一个页面放在WEB-INF中时,重定向到WebContent中的JSP,而不是后者看到的文件。
从登录页面和错误页面看不到Background.jpg。从聊天页面可以看到。

发布于 2014-12-08 02:09:35
如果你有Eclipse,你必须把图片放在这里:
workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/ProjectName
然后写下
background-image: url(<%request.getContextPath()%>/background.jpg);看起来像CSS,但我不知道CSS,所以我不确定上面的代码是正确的。例如,在HTML中,正确的语法是:
<img src="<%=request.getContextPath()%>\Background.jpg">发布于 2014-12-08 03:25:00
所以。原因是筛选器必须重定向来自未登录用户的所有请求。添加后
String currPage = req.getRequestURI();
if (!currPage.endsWith("jpg") && !currPage.endsWith("css")) {doFilter()}它起作用了!
https://stackoverflow.com/questions/27345505
复制相似问题