xml - Why is ControllerClassNameHandlerMapping needed -
i thought controllerclassnamehandlermapping mapping url controller (after removing controller portion) doesnt seem case example.
if remove "/navigation" mapping navigation controller (see below) 404 errors.
<bean class="org.springframework.web.servlet.mvc.support.controllerclassnamehandlermapping" /> <bean name="navigationcontroller" class="com.mvc.controller.navigationcontroller"> <property name="methodnameresolver"> <bean class="org.springframework.web.servlet.mvc.multiaction.propertiesmethodnameresolver"> <property name="mappings"> <props> <prop key="/navigation/menu">menuhandler</prop> </props> </property> </bean> </property> </bean>
in code snippet above need pass property key /navigation/menu thought if /navigation mapped controller away passing /menu otherwise point of controllerclassnamehandlermapping?
i tried removing controllerclassnamehandlermapping needed.
can explain controllerclassnamehandlermapping doing?
thanks
the controllerclassnamehandlermapping
mapping:
/navigation/* -> navigationcontroller.
if remove it, navigationcontroller never executed , lost chances map url method.
the workflow is:
dispatcherservlet -> controllerclassnamehandlermapping -> navigationcontroller -> methodnameresolver -> method
edit
for example if want map "menu" directy menuhandler method use following methodnameresolver
public class lastpathnamemethodresolver extends abstracturlmethodnameresolver { private properties mappings; @override protected string gethandlermethodnameforurlpath(string urlpath) { return mappings.getproperty(stringutils.substringafterlast(urlpath, "/")); } public properties getmappings() { return mappings; } public void setmappings(properties mappings) { this.mappings = mappings; }
Comments
Post a Comment