Build spring MVC today, and the results make a request always no mapping found for HTTP request with URI [******]
So began to troubleshoot a half-day, later on the internet found the concept of parental context,
Just know that every dispatcherservlet of SPRINGMVC will produce a webapplicationcontext ( sub-context ),
It is stored in ServletContext with the Webapplicationcontext ( parent context ) generated by spring initialization
All controller objects must be stored in the SPRINGMVC sub-context , otherwise cannot be found: no mapping found for HTTP request.
- In the parent context (Applicationcontext.xml), exclude the controller's annotations
<base-package= "com"> <type = "Annotation" expression = "Org.springframework.stereotype.Controller" /> </ Context:component-scan >
Only the controller is scanned in the SPRINGMVC configuration file
<base-package= "Org.apollo.controller">< type = "Annotation" expression = "Org.springframework.stereotype.Controller" /> </ Context:component-scan >
and if Parent Context service is configured with a transaction in the the service object cannot be scanned in the child context , otherwise the service transaction is invalidated.
SPRINGMVC Parent Context-led No mapping found for HTTP request