-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Allow ControllerClassNameHandlerMapping and @Controller to work together [SPR-4129] #8808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Juergen Hoeller commented As of Spring 2.5.3, ControllerClassNameHandlerMapping detects This will be available in the next 2.5.3 snapshot (http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). Feel free to give it a try... Juergen |
Matt Raible commented This doesn't seem to work like I expect it to. Here's what I'd expect:
<context:component-scan base-package="org.appfuse.web.controller"/>
package org.appfuse.web.controller; import org.springframework.stereotype.Controller;
}
The only way I can get #3 to work is if I add <bean id="urlMapping" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/> Thanks, Matt |
Tom Duffey commented Any response to Matt's comments? I upgraded from 2.5.2 and had to revert back because it didn't work as expected and like Matt I thought the ControllerClassNameHandlerMapping would determine the request mapping path. |
Keith Donald commented In Matt's example the index method on HomeController would be mapped to the URL /home/index by the 2.5.3 convention, which I imagine isn't what he wants. Just to provide more usage examples of this feature, here is an example in the Spring MVC + Web Flow reference application "booking-mvc". You can see the code on-line here: https://springframework.svn.sourceforge.net/svnroot/springframework/spring-webflow/trunk/spring-webflow-samples/booking-mvc Specifically see: The URls mapped by convention are then: /hotels/index But no, /hotels doesn't mapped to to the index method by default... not in 2.5.3 anyway. Is this the convention you want? Perhaps we could employ a convention to map the root controller URL e.g. /home to a "home" method on the HomeController... |
Matt Raible commented Thanks Keith - your webmvc-config.xml seems to contain the magic sauce that makes this work as expected. Adding the following allows /home/index.html to work:
Additionally adding the URL mapping bean below allows /home.html to work:
Is it possible to make these the defaults or would that mess up too much backwards compatibility? The next thing I'm going to ask for is to eliminate Thanks, Matt |
Matt Raible commented BTW, is there anything being done to allow extensionless URLs? I'd love to have /home/index or home instead of /spring/home or /home.html. I realize I can use UrlRewriteFilter, but it seems like I'd have to add entries for each Controller's URL to my urlrewrite.xml. |
Tom Duffey commented For what it's worth, I finally just got back to this issue and solved it by extending ControllerClassNameHandlerMapping with my own isMultiActionControllerType() method. Mine has an extra check to see if the controller has the This is how must of the controllers in our application are setup ( |
Matt Raible opened SPR-4129 and commented
It would be nice if ControllerClassNameHandlerMapping and
@Controller
could work together. So the URLs could be determined by ControllerClassNameHandlerMapping and you could simply add@Controller
and@Autowired
to your controllers.The following URL contains more information on this (missing) feature:
http://forum.springframework.org/showthread.php?p=151750
Affects: 2.5 RC2
Issue Links:
4 votes, 5 watchers
The text was updated successfully, but these errors were encountered: