Hello all,
I am trying to map multiple dispatch servlets to different contexts as such:
/api/* -> DispatchServlet1
/service/* -> DispatchServlet2
absolute paths:
/api/resources -> package1.class1.method1
/service/resources -> package2.class2.method1
Within DispatchServlet1 servlet-context file, I configured to do component-scanning in package1 which has Class1 definition as so:Code:<servlet-mapping> <servlet-name>DispatchServlet2</servlet-name> <url-pattern>/service/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>DispatchServlet1</servlet-name> <url-pattern>/api/*</url-pattern> </servlet-mapping>
Within DispatchServlet2 servlet-context file, I configured to do component-scanning in package2 which has Class2 definition as so:Code:@Controller public class Class1 { @RequestMapping(value = "/resources", method = RequestMethod.GET) public ResponseEntity<String> method1() {...} }
However, with the above configuration, I get the following exception:Code:@Controller public class Class2 { @RequestMapping(value = "/resources", method = RequestMethod.GET) public ResponseEntity<String> method1() {...} }
How can I fix the above? Use a non-DefaultAnnotationHandlerMapping?Code:Cannot map handler 'class2' to URL path [/resources]: There is already handler of type [class package2.Class2] mapped.
Thanks,
Chandra


Reply With Quote