public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; String contextPath = req.getContextPath(); if (contextPath.equals("/")) { contextPath = ""; } String path = RequestUtil.getPath(req); if (!processDirectAccess(request, response, chain, path)) { return; } reloadRoutes(); if (path.indexOf('.') < 0) { // If the request pass via reverse proxy, the original path must be gotten from HTTP header. if (!contextSensitive) { path = getOriginalPath(req); } try { Options options = Routes.recognizePath(path); String controller = options.getString("controller"); String action = options.getString("action"); Options params = options.except("controller", "action"); String actionPath = ControllerUtil.fromClassNameToPath(controller); S2Container container = SingletonS2ContainerFactory.getContainer(); if (container.hasComponentDef(actionPath.replace('/', '_').concat("Action"))) { S2ExecuteConfig executeConfig; if (StringUtil.equals(action, "index")) { executeConfig = S2ExecuteConfigUtil.findExecuteConfig("/" + actionPath, req); action = executeConfig.getMethod().getName(); } else { executeConfig = S2ExecuteConfigUtil.findExecuteConfig("/" + actionPath, action); } if (executeConfig != null) { StringBuilder forwardPath = new StringBuilder(256); forwardPath .append("/") .append(actionPath) .append(".do?SAStruts.method=") .append(URLEncoderUtil.encode(action)); for (String key : params.keySet()) { forwardPath .append("&") .append(URLEncoderUtil.encode(key)) .append("=") .append(URLEncoderUtil.encode(params.getString(key))); } logger.debug(String.format("recognize route %s as %s#%s.", path, actionPath, action)); req.getRequestDispatcher(forwardPath.toString()).forward(req, res); return; } } } catch (RoutingException e) { if (!fallThrough) throw e; } } chain.doFilter(request, response); }