Favicon.ico not showing up in spring mvc

I am trying to add favicon.ico using spring mvc 4 and apache tomcat 7 (in firefox). I reviewed a lot of solutions, but no one works.

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 options ...).

I placed the favicon.ico file right under the webapps (in other files).

When the page loads, the icon does not appear.

Note . I tried to download the icon directly 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 another favicon.ico, but the icon looks damaged.

When checking items in firefox, I don't call ant in favicon.ico.

Any suggestion?

Update: in my eclipse console, I see:

/ 15: 48: 05.622 [http-bio-8080-exec-6] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - [/] 15: 48: 05.622 [http-bio-8080-exec-6] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - / 15: 48: 05.623 [http-bio-8080-exec-6] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - [/] 15: 48: 05.623 [http-bio-8080-exec-6] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - [/] HandlerExecutionChain [org.springframework.web.servlet.mvc.ParameterizableViewController@380baa3a] 1

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>

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>

3 /, PARTIALLY ( ) , firefox.

, Mike

+4
2

FireFox Chrome: . . , :

web.xml:

<mime-mapping>
    <extension>ico</extension>
    <mime-type>image/x-icon</mime-type>
</mime-mapping>

MVC--servlet.xml:

<mvc:resources mapping="/resources/**" location="/resources/mytheme/" />

( <mvc:default-servlet-handler /> )

genericpage.tag( , jsp):

<link rel="shortcut icon" href='<c:url value="/resources/images/favicon.ico" />' type="image/x-icon">
<link rel="icon" href='<c:url value="/resources/images/favicon.ico" />' type="image/x-icon">

: , <c:rul value= href, .

:

Web pages
+--META-INF
+--WEB-INF
+--resources
   +--mytheme
      +--css
      +--images
         +--favicon.ico

- , /resources/mytheme/

+2

favicon.ico - WEB-INF.

 <link href="/favicon.ico" rel="icon" type="image/x-icon">
+1

All Articles