个人博客 地址:http://www.wenhaofan.com/article/20180926013919
public class PjaxInterceptor implements Interceptor{ IndexService service=IndexService.me; @Override public void intercept(Invocation inv) { Controller c=inv.getController(); boolean isPjax = "true".equalsIgnoreCase(c.getHeader("X-PJAX")); c.setAttr("isPjax", isPjax); inv.invoke(); } }
将该拦截器注册为全局拦截器即可在模板中根据不同情况渲染出不同的页面