从Spring MVC添加favicon [英] Add favicon from Spring MVC

查看:731
本文介绍了从Spring MVC添加favicon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在春季mvc应用程序中作为一个新的蜜蜂工作。我需要为没有任何通用文件的应用程序设置一个favicon来执行此操作。因此,我没有为所有JSP放置相关的代码行,而是考虑使用application-servlet.xml来调用任何HTTP请求。一个人可以帮助我这样做吗?
欢迎您提出任何其他简单方法。

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-
我在想,为任何请求执行javascript代码,可能对此有所帮助。但不确定这是否可行以及如何做到这一点

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

推荐答案

只是为了扩展NimChimpsky的anwer ...把在根(或图像)目录中的favicon,并在JSP页面中以通常的方式引用它(或者更好地仍然使用SiteMesh指定它一次)。例如

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" />

但是在使用Tomcat时会出现问题,因为在网络应用中不会提供favicon因为它是一种未知的矿井类型。修复了在web.xml中添加自定义mime类型的条目:

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>

这篇关于从Spring MVC添加favicon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆