Issue
I am having problems displaying an image in my .jsp
file.
The image no_image.jpg
is located inside the following directory of my Spring MVC application:
SpringProject\src\main\webapp\assets\images\no_image.jpg
I am trying to access it through my .jsp file like this:
<img src="${pageContext.request.contextPath}/assets/images/no_image.jpg"></a>
Project structure (using apache Netbeans IDE 11):
However this does not seem to display the image, does anyone have any ideas why?
Solution
I have found the solution. For anyone else experiencing this issue, a possible solution is to put the following into your spring configuration .xml
file: (Where you define your base package for the project, my one is named spring-config.xml
)
<mvc:resources mapping="/assets/**" location="/assets/"/>
Answered By - MartynasJankus
Answer Checked By - Katrina (JavaFixing Volunteer)