I need some help with URL mapping, in my code when i go to:
http://localhost:8080/register.asdf
http://localhost:8080/register.asddsdsd etc.
it always returns http://localhost:8080/register
but I want to make it 404 NOT FOUND.
How can I fix this?
public class WebInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(Config.class);
ctx.setServletContext(servletContext);
Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
servlet.addMapping("/");
servlet.setLoadOnStartup(1);
}
}
@Controller
public class UserController {
@RequestMapping(path = "/register", method = RequestMethod.GET)
public String registerGet(Model model) {
return "register";
}
EDIT : i added following code in Config.java and solved thanks.
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false);
}