BAEL-1627 Moved the code to new module spring-boot-mvc
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.springbootmvc;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringBootMvcApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBootMvcApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.baeldung.springbootmvc.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
|
||||
@Configuration
|
||||
public class FaviconConfiguration {
|
||||
@Bean
|
||||
public SimpleUrlHandlerMapping myFaviconHandlerMapping() {
|
||||
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
|
||||
mapping.setOrder(Integer.MIN_VALUE);
|
||||
mapping.setUrlMap(Collections.singletonMap("/favicon.ico", faviconRequestHandler()));
|
||||
return mapping;
|
||||
}
|
||||
|
||||
@Bean
|
||||
protected ResourceHttpRequestHandler faviconRequestHandler() {
|
||||
ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler();
|
||||
ClassPathResource classPathResource = new ClassPathResource("com/baeldung/images");
|
||||
List<Resource> locations = Arrays.asList(classPathResource);
|
||||
requestHandler.setLocations(locations);
|
||||
return requestHandler;
|
||||
}
|
||||
|
||||
//@Controller
|
||||
static class FaviconController {
|
||||
|
||||
@RequestMapping(value="favicon.ico", method=RequestMethod.GET)
|
||||
@ResponseBody
|
||||
void favicon() {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user