mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Add favicon.ico
This commit is contained in:
parent
10573d2c74
commit
00c227ac01
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.bootstrap.autoconfigure.web;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@ -31,6 +34,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.GenericConverter;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.format.Formatter;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.web.accept.ContentNegotiationManager;
|
||||
@ -42,6 +47,8 @@ import org.springframework.web.servlet.config.annotation.DefaultServletHandlerCo
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
import org.springframework.web.servlet.view.BeanNameViewResolver;
|
||||
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
|
||||
|
||||
@ -113,6 +120,10 @@ public class WebMvcAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/resources/**").addResourceLocations("/")
|
||||
.addResourceLocations("classpath:/META-INF/resources/")
|
||||
.addResourceLocations("classpath:/resources")
|
||||
.addResourceLocations("classpath:/");
|
||||
registry.addResourceHandler("/**").addResourceLocations("/")
|
||||
.addResourceLocations("classpath:/META-INF/resources/")
|
||||
.addResourceLocations("classpath:/static")
|
||||
@ -121,4 +132,25 @@ public class WebMvcAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class FaviconConfiguration {
|
||||
|
||||
@Bean
|
||||
public SimpleUrlHandlerMapping faviconHandlerMapping() {
|
||||
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
|
||||
mapping.setOrder(Integer.MIN_VALUE + 1);
|
||||
mapping.setUrlMap(Collections.singletonMap("**/favicon.ico",
|
||||
faviconRequestHandler()));
|
||||
return mapping;
|
||||
}
|
||||
|
||||
@Bean
|
||||
protected ResourceHttpRequestHandler faviconRequestHandler() {
|
||||
ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler();
|
||||
requestHandler.setLocations(Arrays.<Resource> asList(new ClassPathResource(
|
||||
"/")));
|
||||
return requestHandler;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
BIN
spring-bootstrap/src/main/resources/favicon.ico
Normal file
BIN
spring-bootstrap/src/main/resources/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 306 B |
Loading…
Reference in New Issue
Block a user