0

I am using Maven project and I am trying to display Image, Below is my code for header part,

<div>
        <div id="header-top">
                <ul class="lang-nav">
                    <li><a  id="active" href="" title="en">EN</a></li>
                    <li><a href="" title="fr">FR</a></li>
                    <li><a href="" title="nl">NL</a></li>
                </ul>
        </div>
        <div id="header-bottom">
            <img src="/resources/images/Mobistar.jpg" />
        </div>
    </div>

servlet-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:component-scan base-package="com.mobistar.eidsar.controller" />
    <context:property-placeholder location="classpath:validation.properties"/>
    <mvc:annotation-driven />
    <mvc:resources mapping="/resources/**" location="/resources/" />

    <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="validation" />
    </bean>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/views/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
</beans>    

I have my images path in /eidsar/src/main/webapp/resources/images/Mobistar.png and my jsp in /eidsar/src/main/webapp/WEB-INF/views/header.jsp, I am not able to see the image. Any help would be highly appreciated. Dont mark this as duplicate as I havenot found any solution yet.

2
  • see in your browser's console :the path used for the image. Now match that path in your war file. Commented Mar 7, 2016 at 5:04
  • This link helped me to get the solution, stackoverflow.com/questions/20369529/… Thanks! Commented Mar 7, 2016 at 5:51

1 Answer 1

0
Use the context path like this:
<div id="header-bottom">
 <img src="<%=request.getContextPath()%>/resources/images/Mobistar.jpg" />
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.