跳到主要内容

14.4 baseViewPath

baseViewPath 设置由原来的configConstant(…) 方法中转移到了Routes 对象中,并且可以对不同的Routes对象分别设置,如下是示例:

public class FrontRoutes extends Routes {

  public void config() {
    setBaseViewPath("/_view");

    add("/", IndexController.class, "/index");
    add("/project", ProjectController.class);
  }
}

从configConstant(…)转移到configRoute(…)中的好处是可以分别对不同的Routes进行设置,不同模块的baseViewPath很可能不相同,从而可以减少冗余代码。上面的代码示例是用于Routes拆分后的情况,如果你的应用并没有对Routes进行拆分,只需要在configRoute 中如下配置即可:

public void configRoute(Routes me) {
   me.setBaseViewPath("/_view");

   me.add("/", IndexController.class);
}

版权声明:「DDKK.COM 弟弟快看,程序员编程资料站」本站文章,版权归原作者所有

JFinal 官方 | https://jfinal.com