java - Spring MVC configuration enable -


i'm setting project scratches, i'm on step of configuring spring mvc 4.1.5 using java config. whole app beeing run on tomcat gradle plugin.

can explain me why need make following call class defaultservlethandlerconfigurer in order make requests map controllers ?

@override public void configuredefaultservlethandling(defaultservlethandlerconfigurer configurer) {     configurer.enable(); } 

without enabling requests beeing rejected , server says there no mapping particular request.

i read spring doc find out, description doesn't tell me much.

enable forwarding "default" servlet. when method used defaultservlethttprequesthandler try auto-detect "default" servlet name. alternatively, can specify name of default servlet via enable(string).

it's explained in spring mvc section documentation here.

this allows mapping dispatcherservlet "/" (thus overriding mapping of container’s default servlet), while still allowing static resource requests handled container’s default servlet. configures defaultservlethttprequesthandler url mapping of "/**" , lowest priority relative other url mappings.

this handler forward requests default servlet. therefore important remains last in order of other url handlermappings. case if use or alternatively if setting own customized handlermapping instance sure set order property value lower of defaultservlethttprequesthandler, integer.max_value.

that piece of code equivalent xml line <mvc:default-servlet-handler/> in spring web mvc-specific components file defined servletname-servlet.xml

you have use call in order configure forwarding spring default servlet, if don't make server try use own servlet handling , explained, if don't have specific defined won't find mapping requests.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -