I'm referring my resources in my Spring project as below
dispatcher-servlet.xml
<mvc:resources mapping="/resources/**" location="/resources/" />
jsp files
<script src="<c:url value="/resources/js/jquery-1.11.1.min.js" />"></script>
<script src="<c:url value="/resources/js/startpage.js" />"></script>
<link href="<c:url value="/resources/css/startpage.css" />" rel="stylesheet">
Now, I have a "image" folder within the resources folder and I want to refer few images in my css files.
How can I refer that?
You could put img
tag to your .jsp file
<img src="${pageContext.servletContext.contextPath}/resources/image/picture1.png" alt="" title="" />
edit1. In the css file
#yourcssclass {
width: 46px;
height: 44px;
background: url(/resources/image/picture1.png) 0 0;
}
Its all about relativity.
Lets say your resource folder is broken down into: -image -js -css
If you have file in css test.css you wish to edit to include image from image folder, you need to do something like following.
#testdiv {
background-image: url('../image/testimage.jpg')
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.