Java WAR 文件中的 favicon.ico

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/399286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 12:13:11  来源:igfitidea点击:

favicon.ico in Java WAR file

javajakarta-eewarfavicon

提问by djsnowsill

Can anybody provide some instruction on how to setup a war file to show a favicon.ico in the browser address bar?

任何人都可以提供一些有关如何设置War文件以在浏览器地址栏中显示 favicon.ico 的说明吗?

回答by stian

You can also use the following HTML markup in your HTML:

您还可以在 HTML 中使用以下 HTML 标记:

<link rel="icon" type="image/gif" href="/img/image.gif">

Most newer browsers should support it and I think it's generally a more clean way since you can use any image type/name/location you want.

大多数较新的浏览器都应该支持它,我认为这通常是一种更干净的方式,因为您可以使用任何您想要的图像类型/名称/位置。

回答by neesh

This might be different in different application servers. For tomcat, the favicon comes from the directory your root context is mapped to. So if your application is mapped to the root context [/], just place the favicon.ico file in the top level folder in your war file.

这在不同的应用程序服务器中可能会有所不同。对于 tomcat,图标来自您的根上下文映射到的目录。因此,如果您的应用程序映射到根上下文 [/],只需将 favicon.ico 文件放在您的 war 文件的顶级文件夹中。