Moved code of article spring-handler-mappings from spring-mvc-java to spring-mvc-basics
Renamed beans to avoid collisions
This commit is contained in:
parent
802000d545
commit
1e9364a7dc
|
@ -9,4 +9,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||
- [Spring MVC Tutorial](https://www.baeldung.com/spring-mvc-tutorial)
|
||||
- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller)
|
||||
- [Using Spring ResponseEntity to Manipulate the HTTP Response](http://www.baeldung.com/spring-response-entity)
|
||||
- [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial)
|
||||
- [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial)
|
||||
- [Guide to Spring Handler Mappings](http://www.baeldung.com/spring-handler-mappings)
|
|
@ -1,11 +1,10 @@
|
|||
package com.baeldung.config;
|
||||
|
||||
import com.baeldung.web.controller.handlermapping.WelcomeController;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
|
||||
import com.baeldung.web.controller.handlermapping.WelcomeController;
|
||||
|
||||
@Configuration
|
||||
public class BeanNameUrlHandlerMappingConfig {
|
||||
|
@ -16,7 +15,7 @@ public class BeanNameUrlHandlerMappingConfig {
|
|||
}
|
||||
|
||||
@Bean("/beanNameUrl")
|
||||
public WelcomeController welcome() {
|
||||
public WelcomeController welcomeBeanNameMappingConfig() {
|
||||
return new WelcomeController();
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ public class HandlerMappingDefaultConfig {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public WelcomeController welcome() {
|
||||
public WelcomeController welcomeDefaultMappingConfig() {
|
||||
return new WelcomeController();
|
||||
}
|
||||
|
|
@ -16,14 +16,14 @@ import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
|||
public class HandlerMappingPrioritiesConfig {
|
||||
|
||||
@Bean
|
||||
BeanNameUrlHandlerMapping beanNameUrlHandlerMapping() {
|
||||
BeanNameUrlHandlerMapping beanNameUrlHandlerMappingOrder1() {
|
||||
BeanNameUrlHandlerMapping beanNameUrlHandlerMapping = new BeanNameUrlHandlerMapping();
|
||||
beanNameUrlHandlerMapping.setOrder(1);
|
||||
return beanNameUrlHandlerMapping;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SimpleUrlHandlerMapping simpleUrlHandlerMapping() {
|
||||
public SimpleUrlHandlerMapping simpleUrlHandlerMappingOrder0() {
|
||||
SimpleUrlHandlerMapping simpleUrlHandlerMapping = new SimpleUrlHandlerMapping();
|
||||
simpleUrlHandlerMapping.setOrder(0);
|
||||
Map<String, Object> urlMap = new HashMap<>();
|
||||
|
@ -37,7 +37,7 @@ public class HandlerMappingPrioritiesConfig {
|
|||
return new SimpleUrlMappingController();
|
||||
}
|
||||
|
||||
@Bean("/welcome")
|
||||
@Bean("/welcome-priorities")
|
||||
public BeanNameHandlerMappingController beanNameHandlerMapping() {
|
||||
return new BeanNameHandlerMappingController();
|
||||
}
|
|
@ -18,7 +18,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
|||
public class SimpleUrlHandlerMappingConfig {
|
||||
|
||||
@Bean
|
||||
public ViewResolver viewResolver() {
|
||||
public ViewResolver viewResolverSimpleMappingConfig() {
|
||||
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
|
||||
viewResolver.setPrefix("/");
|
||||
viewResolver.setSuffix(".jsp");
|
||||
|
@ -29,13 +29,13 @@ public class SimpleUrlHandlerMappingConfig {
|
|||
public SimpleUrlHandlerMapping simpleUrlHandlerMapping() {
|
||||
SimpleUrlHandlerMapping simpleUrlHandlerMapping = new SimpleUrlHandlerMapping();
|
||||
Map<String, Object> urlMap = new HashMap<>();
|
||||
urlMap.put("/simpleUrlWelcome", welcome());
|
||||
urlMap.put("/simpleUrlWelcome", welcomeSimpleMappingConfig());
|
||||
simpleUrlHandlerMapping.setUrlMap(urlMap);
|
||||
return simpleUrlHandlerMapping;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WelcomeController welcome() {
|
||||
public WelcomeController welcomeSimpleMappingConfig() {
|
||||
return new WelcomeController();
|
||||
}
|
||||
|
|
@ -17,7 +17,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||
- [Circular Dependencies in Spring](http://www.baeldung.com/circular-dependencies-in-spring)
|
||||
- [Introduction to HtmlUnit](http://www.baeldung.com/htmlunit)
|
||||
- [Spring @RequestMapping New Shortcut Annotations](http://www.baeldung.com/spring-new-requestmapping-shortcuts)
|
||||
- [Guide to Spring Handler Mappings](http://www.baeldung.com/spring-handler-mappings)
|
||||
- [Upload and Display Excel Files with Spring MVC](http://www.baeldung.com/spring-mvc-excel-files)
|
||||
- [Spring MVC Custom Validation](http://www.baeldung.com/spring-mvc-custom-validator)
|
||||
- [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config)
|
||||
|
|
Loading…
Reference in New Issue