Hello there.
Is it possible to use a MultiActionController, configured with the default InternalPathMethodNameResolver, and mapped with BeanNameUrlHandlerMapping ?
I've tried to do this but so far I'm not successful. Unless this is not possible( I'd be surprised), there must be something I'm doing wrong. Here is how I tried.
My DispatcherServlet is mapped like this :
Note that the servlet is mapped on "/". This is because when at first I did map it on "/*", but this way there were problems resolving views. I think that is because the default InternalResourceViewResolver uses the request dispatcher, that in turn did map our jsp servlet to the dispatcher, wich tried to map our jsp name to a controller... So Mapping all our requests to "/" did solve that problem ...Code:<servlet> <servlet-name>core</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>core</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
My controller is configured like this :
No specific handler mapping are defined, so the default BeanNameUrlHandlerMapping is used. My controller looks like this :Code:<bean name="/book/search" class="com.sample.x.samples.bookbay.search.SearchController"/>
According to what I read in the documentation, I tough that calling my url like this :Code:public class SearchController extends MultiActionController { public ModelAndView getForm(HttpServletRequest request, HttpServletResponse response) { ModelAndView mav = new ModelAndView("/book/searchForm.jsp"); return mav; } public ModelAndView performSearch(HttpServletRequest request, HttpServletResponse response) { ModelAndView mav = new ModelAndView("/book/searchForm.jsp"); handleFormSubmission(request, mav); return mav; } ...
http://myHost/myApp/book/search/getForm
would make the getForm method of my controller called. But instead, the dispatcher servlet tells me that no Controller called "/book/search/getForm" have been found.
My understanding was that since the BeanNameUrlHandlerMapping was used, that my controller would match "/book/search", and that since the InternalPathMethodNameResolver is used, we had to add "/methodname" to the url.
Can the BeanNameUrlHandlerMapping be used with a MultiActionController configured with a InternalPathMethodNameResolver ?
If so, can someone point me on what I did wrong ? Is the problem du only to my weird servlet mapping ?


Reply With Quote