I am trying to add a favicon.ico using spring mvc 4 and apache tomcat 7 (in firefox). I examined many solutions but no one seems to work.
web.xml:
<mime-mapping>
<extension>ico</extension>
<mime-type>image/x-icon</mime-type>
</mime-mapping>
mvc-core-config.xml:
<mvc:default-servlet-handler/>
<!-- <mvc:resources mapping="/resources/**" location="/resources/css" /> -->
<mvc:resources location="/favicon.ico" mapping="/favicon.ico" />
jsp:
<link href="MYPROJECT/favicon.ico" rel="icon" type="image/x-icon">
(I also tried without MYPROJECT and other variations...).
I placed favicon.ico file right under webapps (tried in other folders as well).
When loading the page, no icon displayed.
Note: I tried to load directly the icon http://localhost:8080/MYPROJECT/favicon.ico but received the following error message: the image 'http://localhost:8080/MYPROJECT/favicon.ico' cannot be displayed because it contains errors. I downloaded other favicon.ico but the icon looks corrupted.
When inspecting elements in firefox I don't ant call to the favicon.ico.
Any suggestion?
Update: in my eclipse console I see:
Looking up handler method for path / 15:48:05.622 [http-bio-8080-exec-6] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/] 15:48:05.622 [http-bio-8080-exec-6] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path / 15:48:05.623 [http-bio-8080-exec-6] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/] 15:48:05.623 [http-bio-8080-exec-6] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Mapping [/] to HandlerExecutionChain with handler [org.springframework.web.servlet.mvc.ParameterizableViewController@380baa3a] and 1 interceptor
Update2 mvc config xml:
<import resource="mvc-view-config.xml"/>
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"/>
<mvc:annotation-driven conversion-service="conversionService"/>
<context:component-scan base-package="controllers,logic.preprocess"/>
<mvc:view-controller path="/" view-name="index" />
<mvc:default-servlet-handler/>
<mvc:resources location="/favicon.ico" mapping="/favicon.ico" />
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
p:basename="messages/messages"/>
</beans>
The included mvc-view-config.xml:
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="viewResolvers">
<list>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<property name="contentType" value="text/html;charset=UTF-8"></property>
</bean>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
<property name="order" value="1"/> </bean>
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
<property name="order" value="2" /> </bean>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="order" value="3" />
<property name="alwaysUseFullPath" value="true" />
<property name="mappings">
<props>
<prop key="controllers/TaskController">taskController</prop>
<prop key="controllers/ResultController">resultController</prop>
</props>
</property>
</bean>
update 3 I placed the file under resources/images and it seems to work PARTIALLY (without shortcut) only on chrome but not on firefox.
Thanks, Mike
