Reputation: 373
I have the problem that my favicon is not showing up if I have deployed the war file. In my IDE its working.
I am using Spring Boot and packacking war. The favicon.ico is stored in the folder src/main/resources and also in src/main/resources/static like in the most pages described. In the packaged war file I also see the favicon.ico. I have linked it also on the jsp page.
Icon is not showing up. I think the problem is that the tomcat is looking in a different folder. Interesting would also why if I start from the IDE its working and if I start the war its not.
Clipping from jsp file
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
Location of "favicon.ico", stored this icon in "src/main/resources" and also in the subfolder static.
Upvotes: 1
Views: 5114
Reputation: 373
I figured it out. My solution was to create a @Requestmapping for favicon.ico to present it from the webserver.
@RequestMapping("favicon.ico")
String favicon() {
return "forward:/myfavicon.ico";
}
Config application.properties
spring.mvc.favicon.enabled=false
And of course placed the icon in the root directory of my application in the IDE.
Upvotes: 1