`
yzhong_sa
  • 浏览: 88741 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类

velocity 学习1 环境配置。

阅读更多
Start with velocity.

1.set the enviroment for velocity:

  (1).New a web project in eclipse.
  (2).Add the jars package to the project .you could find all the
                    jars package needed in jarsForVelocity package.
  (3).Define the servlet for the velocity in the web.xml file :

   <web-app>
      <servlet>
         <servlet-name>velocityView</servlet-name>
          <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
         <init-param>
            <param-name>org.apache.velocity.toolbox</param-name>
            <param-value>/WEB-INF/toolbox.xml</param-value>
        </init-param>
      </servlet>
      <servlet-mapping>
         <servlet-name>velocityView</servlet-name>
         <url-pattern>*.vm</url-pattern>
      </servlet-mapping>
   </web-app>

   Now ,the velocityView will deal with all the *.vm url in
   this project.the toolbox.xml define the module we could
   use.
  (4).New a file toolbox.xml in WEB-INF folder and  edit it like this:

    <?xml version="1.0"?>
     <toolbox>
       <tool>
        <key>date</key>
         <scope>application</scope>
         <class>org.apache.velocity.tools.generic.DateTool</class>
      </tool>
     <tool>
       <key>math</key>
       <scope>application</scope>
       <class>org.apache.velocity.tools.generic.MathTool</class>
     </tool>
    </toolbox>
  (5)Change the default page of this project in web.xml file :

   <welcome-file-list>
    <welcome-file>index.vm</welcome-file>
   </welcome-file-list>
  (6).New a file index.vm :

   #set($hello="Velocity")
   <html>
     <head>
        <title>Hello</title>
     </head>
     <b>
        Hello $hello World !
     </b>
   </html>
  (7).Start the tomcat server and deploy this project ..you could
      see "Hello Velocity World ! " in the page.

  This is the Hello World for the velocity..Next step we will see
  how to access the data .





这是直接在我的工作文档粘帖过来的  懒了点  不过可以看得明白吧。。
分享到:
评论

相关推荐

    公文传输系统velocity struts spring hibernate(lib太大只发截图自己去下)

    1 修改配置文件 1.1 修改Spring配置文件 1.1.1 查找并打开GWCS/WebRoot/WEB-INF/applicationContext.xml文件。 1.1.2 数据库配置 找到“dataSource”定义部分,根据实际情况修改数据库连接属性值,比如连接字符串...

    springboot学习

    chapter2-1-1:配置文件详解:自定义属性、随机数、多环境配置等 chapter2-1-2:2.0 新特性(一):配置绑定全解析 chapter2-2-1:2.0 新特性(二):新增事件ApplicationStartedEvent Web开发 chapter3-1-1:构建一...

    Maven权威指南 很精典的学习教程,比ANT更好用

    1. Creative Commons BY-ND-NC Foreword: Beta 0.16 Preface 1. How to Use this Book 2. Your Feedback 3. Font Conventions 4. Maven Writing Conventions 5. Acknowledgements 1. 介绍 Apache Maven ...

    spring boot 全面的样例代码

    - chapter2-1-1:[配置文件详解:自定义属性、随机数、多环境配置等](http://blog.didispace.com/springbootproperties/) ### Web开发 - chapter3-1-1:[构建一个较为复杂的RESTful API以及单元测试]...

    极速开发环境 jfinal1.2

    JFinal 是基于 Java 语言的极速 WEB + ORM 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。在拥有Java语言所有优势的同时再拥有ruby、python、php等动态语言的开发效率!...

    基于SpringBoot+SpringCloud+Mybatis主流框架搭建的分布式敏捷开发系统架构+源代码+文档说明

    分布式统一配置管理中心,可解决多环境多项目配置 &gt; mi-api 接口总线服务,提供eureka注册中心。其他模块需暴露API接口可参考此案例或者在自己子项目中创建服务提供者供其他项目调用消费。 &gt; mi-admin 平台总...

    电子商城系统设计实习报告.doc

    16 7.2 逻辑结构 18 7.2.1 数据表结构详细设计 18 7.2.2 数据库表之间的关系设计 19 8 程序效果展示 20 8.1 前台功能模块 20 8.2 后台功能模块 22 9 实习总结体会 27 实习内容简述 1 实习期间完成的学习内容: 1 ...

    SpringMVC_HelloWorld:SpringMVC的一个hello world的demo,开启学习SpringMVC的大门

    SpringMVC 框架提供了一个DispatchServlet作为前端控制器来分派请求,同时提供灵活的配置处理程序映射,视图解析,语言环境和主题解析,并支持文件上传。SpringMVC还包含多种视图技术,例如 JSP,Velocity,Tiles,...

    大数据时代的医学数据共享.docx

    大数据时代医学数据共享出现的问题 1.1 数据共享的难度较大 医学实现数据资源共享,是各个医疗机构互相学习借鉴的机会,是促进学术交流的平台,是提升医疗内部工作人员数字信息化思维模式转变和提升的环境。...

    我对大数据的看法.pdf

    ⼤数据的4V特点:Volume(⼤量)、Velocity(⾼速)、Variety(多样)、Veracity(精 确)。⼤数据最核⼼的价值就是在于对于海量数据进⾏存储和分析。 ⼤数据通常⽤来形容⼀个创造的⼤量⾮结构化和半结构化数据,...

    外文翻译 stus MVC

    1:外文原文 Struts——an open-source MVC implementation This article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help...

    Struts2 in action中文版

    第1章 Struts 2:现代Web框架 2 1.1 Web应用程序:快速学习 2 1.1.1 构建Web应用程序 2 1.1.2 基础技术简介 3 1.1.3 深入研究 6 1.2 Web应用程序框架 7 1.2.1 什么是框架 7 1.2.2 为什么使用框架 8 1.3 Struts 2框架...

Global site tag (gtag.js) - Google Analytics