zoukankan      html  css  js  c++  java
  • ssh2整合velocity出现Unable to find resource

    org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'index.html'
     at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
     at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
     at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
     at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:317)
     at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:378)
     at service.HomepageService.updateIndex(HomepageService.java:52)
    ...

    解决办法:加上下面这段即可

        String vmPath =ServletActionContext.getRequest().getSession().getServletContext().getRealPath("");
        Properties p = new Properties();
        p.setProperty("file.resource.loader.path", vmPath+"//");

        //初始化vm模板
        Velocity.init( p );
       Template template=Velocity.getTemplate("index.html","UTF-8");

  • 相关阅读:
    mysql事务
    mysql函数
    mysql自连接
    MYSQL添加外键关联
    SQL多表查询
    SQL数据完整性
    SQL limit
    SQL分组查询
    升级GCC 6.2编译LLVM的问题
    Quartz时SLF4J错误
  • 原文地址:https://www.cnblogs.com/kivi/p/3192251.html
Copyright © 2011-2022 走看看