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
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>
Just store favicon.ico
in the root of webapp (aka the one up from WEB-INF) directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With