Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse 日食+;ApacheVelocity引擎?_Eclipse_Tomcat_Jar_Virtual Machine_Velocity - Fatal编程技术网

Eclipse 日食+;ApacheVelocity引擎?

Eclipse 日食+;ApacheVelocity引擎?,eclipse,tomcat,jar,virtual-machine,velocity,Eclipse,Tomcat,Jar,Virtual Machine,Velocity,AppacheVelocity新手,尝试在Eclipse中运行我的第一个vm页面(未成功)。以下是我迄今为止采取的步骤: 下载Velocity引擎分发版: 在Eclipse中创建动态Web项目 选择Tomcat作为服务器 在WebContent文件夹中创建一个简单的index.vm文件 将velocity-1.7.zip中的所有jar文件添加到我的项目类路径中 运行index.vm,按原样输出所有VTL(不是“虚拟机化”) index.vm: <html> <body>

AppacheVelocity新手,尝试在Eclipse中运行我的第一个vm页面(未成功)。以下是我迄今为止采取的步骤:

  • 下载Velocity引擎分发版:
  • 在Eclipse中创建动态Web项目
  • 选择Tomcat作为服务器
  • 在WebContent文件夹中创建一个简单的index.vm文件
  • 将velocity-1.7.zip中的所有jar文件添加到我的项目类路径中
  • 运行index.vm,按原样输出所有VTL(不是“虚拟机化”)
  • index.vm:

    <html>
    <body>
    #set( $foo = "Velocity" )
    Hello $foo World!
    </body>
    <html>
    
    
    #设置($foo=“速度”)
    你好$foo World!
    

    非常感谢您的帮助

    好的,在Eclipse中运行。只需将所有Velocity Jar文件添加到我的动态WEB项目中WEB-INF文件夹的lib目录中。然后更新web.xml,如下所示:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>Velocity_Test</display-name>
      <welcome-file-list>
        <welcome-file>index.vm</welcome-file>  
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
    
      <!-- Define Velocity template compiler -->
      <servlet>
        <servlet-name>velocity</servlet-name>
        <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
      </servlet>
    
      <!-- Map *.vm files to Velocity -->
      <servlet-mapping>
        <servlet-name>velocity</servlet-name>
        <url-pattern>*.vm</url-pattern>
      </servlet-mapping>
    </web-app>
    
    
    速度试验
    index.vm
    index.html
    index.htm
    index.jsp
    default.html
    default.htm
    default.jsp
    速度
    org.apache.velocity.tools.view.servlet.VelocityViewServlet
    速度
    *.vm
    
    附加问题。我从lib文件夹中删除了jar,并将它们添加到我的类路径中。它抛出了一系列错误。我可以从外部指向所有Velocity Jar文件,还是需要将它们导入到项目的lib文件夹中才能工作?谢谢嘿,你能提供一个你的velocity项目的例子吗?我想建立一个,但我有困难。你可以共享你的项目文件夹吗?这样我就可以看到文件的去向了?感谢