小编use*_*465的帖子

面对 java.lang.NoClassDefFoundError 的问题:org/apache/velocity/context/Context

我是一个新的学习速度。我试图通过为此编写一个 servlet 以 HTML 格式显示模板。以下是我的servlet代码

        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            PrintWriter out = response.getWriter();
              VelocityEngine velocityEngine = new VelocityEngine();
              try {
                velocityEngine.init();
                Template template = velocityEngine.getTemplate("./src/Menu.txt");

              VelocityContext context = new VelocityContext();
              context.put( "special-1", "./src/special-1.txt" );
              context.put( "special-2", "./src/special-2.txt" );
              context.put( "special-3", "./src/special-3.txt" );
              StringWriter writer = new StringWriter();
              template.merge(context, writer);
              out.println(writer);
              } catch (Exception e) {
                    e.printStackTrace();
                }
        }
Run Code Online (Sandbox Code Playgroud)

以下是我得到的堆栈跟踪...

    SEVERE: A child container failed during start
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
        at …
Run Code Online (Sandbox Code Playgroud)

apache velocity servlets exception

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

apache ×1

exception ×1

servlets ×1

velocity ×1