JFinal

登录 注册

JFINAL3.3 3.4整合项目时无法访问 模板网页,启动报错

用冷冷 maven3.3 3.4jfinal  在这段代码出问题 me.addSharedFunction("_common/common.html"); 此会出现错误


 Directive not found: #principal


Template: "/WEB-INF/views/index.html". Line: 41


 /**


     * 配置模板引擎


     *


     * @param me Engine


     */


    public void configEngine(Engine me) {


        //如果公共模板中有引用shiro标签,那么这个要在它之前


        initDirective(me);


        me.addDirective("userCount", UserCountTag.class);


        me.addSharedFunction("_common/common.html"); 此会出现错误


    }




    public static void initDirective(Engine me){


Set<Class<?>> classes = ClassUtil.scanPackageByAnnotation(null, true, DefineDirective.class);


for (Class<?> clazz : classes) {


DefineDirective defineDirective = clazz.getAnnotation(DefineDirective.class);


String tag = defineDirective.tag();


if (tag != null && !"".equals(tag)) {


me.addDirective(tag, (Directive) ClassUtil.newInstance(clazz));


} else {


LogKit.error("自定义Directive的标签为空无效:" + clazz.getName());


}


}


}






红色字体代码出现


严重: Exception starting filter jfinal








com.jfinal.template.stat.ParseException: Directive not found: #hasRole


Template: "_common/common.html". Line: 22


at com.jfinal.template.stat.Parser.stat(Parser.java:212)


at com.jfinal.template.stat.Parser.statList(Parser.java:101)


at com.jfinal.template.stat.Parser.stat(Parser.java:175)


at com.jfinal.template.stat.Parser.statList(Parser.java:101)


at com.jfinal.template.stat.Parser.parse(Parser.java:91)


at com.jfinal.template.EngineConfig.doAddSharedFunction(EngineConfig.java:92)


at com.jfinal.template.EngineConfig.addSharedFunction(EngineConfig.java:87)


at com.jfinal.template.Engine.addSharedFunction(Engine.java:238)


at io.github.wx.core.config.LmsCoreConfig.configEngine(LmsCoreConfig.java:78)


at com.jfinal.core.Config.configJFinal(Config.java:53)


at com.jfinal.core.JFinal.init(JFinal.java:63)


at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)


at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)


at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)


at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)


at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4854)


at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5546)


at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)


at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)


at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)


at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)


at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1258)


at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1918)


at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)


at java.util.concurrent.FutureTask.run(FutureTask.java:262)


at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)


at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)


at java.lang.Thread.run(Thread.java:745)




五月 14, 2018 12:55:24 上午 org.apache.catalina.core.StandardContext startInternal


评论

  • 05-14 16:33
    initDirective(...) 方法内部没有添加上 #principal 这些指令而已,你手动用 me.addDirective(....) 添加即可
  • 05-14 21:25
    @JFinal 结局了,波总
  • 05-15 11:55
    @JFinal me.addDirective成功后还是没有进入,不知道什么原因 然后报的错。
  • 05-15 15:20
    @JackZeng 你先好好学习一下 jfinal 使用基础,能省很多时间

    添加指令,配置各种 engine 参数,有详细的文档,如果这样一直猜下去,时间反而浪费更多:http://www.jfinal.com/doc/6-2
  • 05-15 21:40
    @JFinal 我已经跑起来了。。。
  • 05-15 21:41
    @JFinal 波总,thanks
  • 发送