KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This is a cross post. I've also posted the same question to spring forums. http://forum.springsource.org/showthread.php?128579-Database-driven-Controller-Mapping Hi I'm trying to do database driven controller mappings so that they can change at runtime . So far what I have is as follows. Custom Handler Adaptor which can always be optimized later. @Component public class DatabasePageUrlHandlerMapping extends AbstractUrlHandlerMapping implements PriorityOrdered { @Override protected Object getHandlerInternal(HttpServletRequest request) throws Exception { String lookupPath = getUrlPathHelper().getLookupPathForRequest(request); List<Page> pages = Page.findAllPages(); for (Page page : pages) { if (lookupPath.equals(page.getSeoPath())) { Object handler = getApplicationContext().getBean("_pageViewController"); return new HandlerExecutionChain(handler); } } return super.getHandlerInternal(request); } } my webmvc-config looks as follows (the relevant part) Code: <context:component-scan base-package="com.artiststogether" use-default-filters="false"> <context:include-filter expression="org.springframework.stereotype.Controller" type="annotation" /> </context:component-scan> <!-- If I don't put an order into this it doesn't fail over to the implementation why? --> <bean class="com.artiststogether.web.DatabasePageUrlHandlerMapping" p:order="-1" /> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> This appears to be picking up the correct controller. However I recieve an error when going to a database define
Tags (comma-separated)
Save Edits
Cancel