Built-in jetty and icon

I am using Jetty built into my application as follows:

ResourceConfig rc = new PackagesResourceConfig("my.jersey.resources.package"); ServletHolder servletHolder = new ServletHolder(new ServletContainer(rc)); ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); servletContextHandler.addServlet(servletHolder, "/" + customContextPath + "/*"); server.start(); 

Is there a way to add some kind of processing for custom favicon.ico using the above setting?

thanks

+8
java favicon jetty
source share
3 answers

Just adding favicon.ico to the root directory does not work because the browser does not include the application context when retrieving the icon. Add this to your HTML:

 <link rel="shortcut icon" href="images/favicon.ico"> 

Be sure to include the correct absolute or relative path to your sign.

+3
source share

You tried to add favicon.ico to the root directory where your content is located.

+1
source share

This answer may be disconnected from the topic, but I had a problem with gradle jettyRun running the gradle jettyRun . The solution was to explicitly add the favicon.ico file to the root of the archive.

build.gradle

 war { from 'src/main/webapp/favicon.ico' // adds a file-set to the root of the archive } 
0
source share

All Articles