Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add favicon from Spring MVC

I'm working in spring mvc application as a new bee. I need to set up a favicon for the application which does not have any common file to do this. So instead of placing the relevant code lines for all the JSP s, I'm thinking of doing this using application-servlet.xml which calls for any HTTP request. Can anyone help me on doing this with one shot ? You are welcome for suggest any other easy way to do this.

edited- I was thinking that, executing javascript code code for any request, may be help to this. But not sure that is possible as well as how I can do that

like image 587
chanaka777 Avatar asked Dec 04 '12 13:12

chanaka777


2 Answers

Just to expand on NimChimpsky's anwer... put the favicon in the root (or images) directory and reference it the usual way in your JSP pages (or better still use SiteMesh to specify it once). E.g.

<link rel="shortcut icon" type="image/x-icon" href="${pageContext.request.contextPath}/favicon.ico" />

But there is a gotcha when using Tomcat, where the favicon won't get served from inside the webapp due it being a "unknown" mine type. The fix to add a custom mime type entry in web.xml:

<!-- Mimetype needed for tomcat to serve favicon images -->
<mime-mapping>
    <extension>ico</extension>
    <mime-type>image/x-icon</mime-type>
</mime-mapping>
like image 52
nickdos Avatar answered Oct 20 '22 00:10

nickdos


Just store favicon.ico in the root of webapp (aka the one up from WEB-INF) directory

like image 36
NimChimpsky Avatar answered Oct 19 '22 23:10

NimChimpsky