Using Spring, you can extend org.springframework.web.HttpRequestHandler to support your script.
Implement the method:
@Override public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}
Use it to analyze an incoming request, determine if the request URL is part of your special subset of the request URL and redirected to the appropriate location.
Example:
@Override public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (urlPath.contains("/sectionName")) { RequestDispatcher requestDispatcher = request.getRequestDispatcher("sections" + "/" + urlPath); requestDispatcher.forward(request, response); } }
And customize your sections, for example:
@RequestMapping(value={"/sections/{sectionName}"})
This will not interfere with any of your previously existing controller mappings.
source share