先看下请求,上为第一次请求:/sitemap/xml,下为第二次请求:/sitemap.xml
相关代码如下:
@RequestMapping(value = "/sitemap", viewPath = "/view/website/sitemap") public class SiteMapController extends Controller { @Inject SiteMapService service; public void xml(){ System.out.println("[SiteMapController] xml: " + 111); renderText(getByCache("/sitemap/xml", () -> renderToString("sitemap.xml", getAttrs()) ), "xml"); System.out.println("[SiteMapController] xml: " + 222); } }
Handler映射关系:
SITE_MAP_MAPPING.put("/sitemap.xml", "/sitemap/xml"); SITE_MAP_MAPPING.put("/sitemap.txt", "/sitemap/txt"); SITE_MAP_MAPPING.put("/sitemap.html", "/sitemap/html");
控制台输出如下:
JFinal-4.9.09 action report -------- 2021-04-27 17:15:36 -------------------------- Url : GET /sitemap/xml Controller : cn.yuum.sitemap.SiteMapController.(SiteMapController.java:1) Method : xml Interceptor : com.jfinal.ext.interceptor.ExceptionInterceptor.(ExceptionInterceptor.java:1) com.jfinal.ext.interceptor.PermissionInterceptor.(PermissionInterceptor.java:1) cn.yuum.common.interceptor.UserInterceptor.(UserInterceptor.java:1) -------------------------------------------------------------------------------- [SiteMapController] xml: 111 [SiteMapController] xml: 222 com.jfinal.core.ActionException JFinal-4.9.09 action report -------- 2021-04-27 17:15:37 -------------------------- Url : GET /sitemap/xml Controller : cn.yuum.sitemap.SiteMapController.(SiteMapController.java:1) Method : xml Interceptor : com.jfinal.ext.interceptor.ExceptionInterceptor.(ExceptionInterceptor.java:1) com.jfinal.ext.interceptor.PermissionInterceptor.(PermissionInterceptor.java:1) cn.yuum.common.interceptor.UserInterceptor.(UserInterceptor.java:1)
项目:JFinal