2
I’m having trouble showing an image on my JSP page. I’m trying to use several different ways to get the file and I can’t show it on the page.
Folders are arranged as follows
WebContent
|_1.jpg
|_ParaEmpresas.png
|_img
|_1.jpg
|_ParaEmpresas.png
The code on my jsp page
<img src="../../1.jpg"/>
<img src="<c:url value="/img/ParaEmpresas.png"/>" />
<img src="<c:url value="/ParaEmpresas.png"/>" />
and the error when trying to load the page
ADVERTÊNCIA: No mapping found for HTTP request with URI [/DataIdea/img/1.jpg] in DispatcherServlet with name 'springmvc'set 08, 2015 4:13:08 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WEB.XML
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/javaee/web-app_3_0.xsd" id="Webapp_id" version="3.0"> Dataidea
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<resource-ref>
<description>postgreSQL Datasource example</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/WEB-INF/views/erro/erro.jsp</location>
</error-page>
<listener>
<listener-class>br.com.quartz.ListenToMeFirst</listener-class>
</listener>
What is the difference between your JSP and IMG directories? You are probably stating the incorrect path, you can confirm in the browser console if you have given
erro 404– Maicon Carraro
You have Servlet configured to expose the directory publicly?
– flpms
@Brunswick I had already tried using JSP Scriplet. I tried using JSTL and also did not give.
– Victor Henrique
@flpms excuses my ignorance, but since the application is great then and I am new project I had not yet touched the XML, so I updated the question with the code. If you need any information, let me know
– Victor Henrique