Reputation: 221
I am trying to learn Spring MVC. As part of my practice I am using below resource mappings.
@RequestMapping("/training")
public String training(){
return "training";
}
@RequestMapping("/services/training")
public String training(){
return "training";
}
This is the content of my jsp page. <img alt="Bootstrap Image Preview" src="./resources/images/toplogo.png">
. In case 1 it is working fine, but it is expected to be <img alt="Bootstrap Image Preview" src="../resources/images/toplogo.png">
in case 2(One extra . in url)
. I know that this is for accessing the file, but as i want to use this in my template for spring-tiles integration, my expectation is for both type of urls it has to work. Can someone please help me how to achieve this!
Upvotes: 0
Views: 58
Reputation: 243
You should use: spring:url
<spring:url var="url" value="/resources/images/toplogo.png">
<img alt="Bootstrap Image Preview" src="${url}"/>
This should work.
Upvotes: 1