How to display Image in jsp file in spring MVC -
i using maven project , trying display image, below code 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 images path in /eidsar/src/main/webapp/resources/images/mobistar.png , jsp in /eidsar/src/main/webapp/web-inf/views/header.jsp, not able see image. highly appreciated. dont mark duplicate havenot found solution yet.
use context path this: <div id="header-bottom"> <img src="<%=request.getcontextpath()%>/resources/images/mobistar.jpg" /> </div>
Comments
Post a Comment