I have had a really hard time getting my Spring 3.0 application to recognize favicon.ico
type files as a resource. I have defined my resource directory in my spring-context.xml
file as follows:
<mvc:resources mapping="/ui/**" location="/ui/" />
This directory structure looks like:
/ui
/images
/styles
/scripts
...
Spring hosts my images, scripts, and styles just fine. However, I get a 404 error when trying to retrieve any *.ico
files in the images directory. All PNG, GIF, and JPG images work just fine in that same directory. I tried being more specific on which directories to host and even specified .ico
files as resources in the context.xml
file and still get the same results:
<mvc:resources mapping="/ui/images/*.ico" location="/ui/images" />
I've also tried adding a servlet mapping to the default servlet. This seemed to work for some when I researched online, but has not proven successful for me.
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.ico</url-pattern>
</servlet-mapping>
EDIT: I have also added the favicon.ico file to the root path of the web app. If I use a png file for the favicon, it works in every browser but IE. I would like to solve this problem for all browsers if possible. Any help at this point would be greatly appreciated.
EDIT2: I already have a link tag in the XHTML document:
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/ui/images/favicon.ico" />
favicon.ico
has to go in the root path, right? i.e./favicon.ico
, not/ui/favicon.ico
. – Wist