Favicon.ico not showing up in spring mvc 3.2.2 on Tomcat 7.0?

I am new to spring mvc and my favicon.ico is not showing in browser tab using spring 3.2.2 using tomcat 7.0. I tried to look at the search query associated with it, but still I can’t display it on the browser tab (FF, Chrome, IE ... all the latest versions do not work), as well as clearing the cache and restarting the browser.

  • favicon.ico

Located at the root of the webapp folder (src / main / webapp)

  • index.jsp
<!DOCTYPE html>  
      <html> 
         <head>         
            <link href="favicon.ico" rel="shortcut icon" >
  o o o
  • MVC-dispatcher-server.xml
<context:component-scan base-package="com.website.controllers" />

<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>
  • web.xml
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
</context-param>
+3
source share
1 answer

Make sure that the icon is submitted, i.e. make a request to /favicon.ico and check if it appears.

, web.xml, Tomcat Content-Type :

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

, <mvc:default-servlet-handler /> , /.

+3

All Articles