Spring MVC - Mapping wildcard request to template

336 views Asked by At

I have several static pages which use thymeleaf templates. Is it secure/safe to setup one controller to do this? Now I can just add pages to the templates/public directory without having to keep adding controllers.

@RequestMapping(value = "/**", method = RequestMethod.GET)
public String defaultMapping(final HttpServletRequest request) {

   String path="public"+((String) request.getAttribute( HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE ));
    return path;
}
0

There are 0 answers