Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No mapping found for HTTP request with URI [/favicon.ico]

Tags:

spring-mvc

I can't recall what I have changed on my code but whenever I click on any links on my web it gives me this :

WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/favicon.ico] in DispatcherServlet with name 'mvc-dispatcher'

A portion of my web.xml

<servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  </filter>
  <filter>
    <filter-name>HttpMethodFilter</filter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>HttpMethodFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

some configuration of my mvc-dispatcher-servlet.xml

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
        up static resources in the ${webappRoot}/resources directory -->
    <mvc:resources mapping="/resources/**" location="resources/" />

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
        in the /WEB-INF/views directory -->
    <beans:bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
        <beans:property name="order" value="1" />
    </beans:bean>
    <!-- testing for pdf export -->
    <beans:bean class="org.springframework.web.servlet.view.XmlViewResolver">
        <beans:property name="location" value="/WEB-INF/spring-pdf-views.xml" />
        <beans:property name="order" value="0" />
    </beans:bean>

Other than that everything works fine, means any page is loaded correctly without any error. May I know what might cause this ? And who is using that .ico image ?

like image 681
abiieez Avatar asked Jun 11 '13 04:06

abiieez


1 Answers

Most web browsers attempt to fetch a site's favicon at the root of the context with a request for the /favicon.ico resource automatically. In your case is not handled by any configured Spring mapping.

If you have a favicon at /favicon.ico or in another location you could configure a mapping in Spring to resolve the request to a valid resource:

<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
like image 174
andyb Avatar answered Oct 18 '22 05:10

andyb