Add favicon from Spring MVC

我的梦境 提交于 2020-01-01 05:18:08

问题


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


回答1:


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>



回答2:


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




回答3:


<div class="tab-content">
    <div id="frequent"
	class="active tab-pane fade in active text-center">
    <jsp:include page="questionDisplay.jsp" />
    </div>
</div>


来源:https://stackoverflow.com/questions/13703678/add-favicon-from-spring-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!