Below is the method of spring's Dispatcher servlet. If we study this method we can find out if we specify the custom mapping then default mapping(BeanNameUrlHandlerMapping) provided my spring does not registered. This is happening in a separate project other then broadleaf. but in broadleaf BeanNameUrlHandlerMapping is also get registered. i saw it by puttin a debug point on it. I know others handler mapping also get registered but these define are in xml files.
but i did not find the definition of BeanNameUrlHandlerMapping and SimpleUrlHandlerMapping. in xml files
please tell me how these are registered.
Code: Select all
private void initHandlerMappings(ApplicationContext context) {
this.handlerMappings = null;
if (this.detectAllHandlerMappings) {
// Find all HandlerMappings in the ApplicationContext, including ancestor contexts.
Map<String, HandlerMapping> matchingBeans =
[quote]BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HandlerMapping.class, true, false);[/quote]
if (!matchingBeans.isEmpty()) {
this.handlerMappings = new ArrayList<HandlerMapping>(matchingBeans.values());
// We keep HandlerMappings in sorted order.
OrderComparator.sort(this.handlerMappings);
}
}
else {
try {
HandlerMapping hm = context.getBean(HANDLER_MAPPING_BEAN_NAME, HandlerMapping.class);
this.handlerMappings = Collections.singletonList(hm);
}
catch (NoSuchBeanDefinitionException ex) {
// Ignore, we'll add a default HandlerMapping later.
}
}
// Ensure we have at least one HandlerMapping, by registering
// a default HandlerMapping if no other mappings are found.
if (this.handlerMappings == null) {
this.handlerMappings = getDefaultStrategies(context, HandlerMapping.class);
if (logger.isDebugEnabled()) {
logger.debug("No HandlerMappings found in servlet '" + getServletName() + "': using default");
}
}
}