I am confused with how Spring MVC's url-pattern mapping works.
When 'getServletMappings' returns "/",I can get the right response with "http://localhost:8080/hello".
but not working if i change it to "/app" and change url to "http://localhost:8080/app/hello", it returns 404 error.
Am I misunderstanding something, I also find that "/app/*" can work(i can understand this), but why cannot "/app"?
Please check my code:
public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected String[] getServletMappings() {
// works with http://localhost:8080/hello
return new String[] {
"/"
};
// NOT working with http://localhost:8080/app/hello
// return new String[] {
// "/app"
//};
}
}
@RestController
public class HTTPMethodsController {
@RequestMapping("/hello")
public String hello() {
return "Hello SpringMVC.";
}
}