HTTL(Hyper-Text Template Language)是一个适用于HTML输出的开源JAVA模板引擎,适用于动态HTML页面输出,可用于替代JSP页面,它的指令类似于Velocity。
HTTL采用类似于JSP的原理,将模板编译成Java字节码运行,但比JSP的EL更进一步,使用强类型推导,减少运行期反射和转型,更加快速.
缺省配置下,HTTL不需要依赖任何三方类库即可运行。
Maven依赖
已发布到Maven中央库:http://central.maven.org/maven2/com/github/httl/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
< project > < dependencies > < dependency > < groupId >com.github.httl</ groupId > < artifactId >httl</ artifactId > < version >1.0.11</ version > </ dependency > <!-- <dependency> <groupId>com.github.httl</groupId> <artifactId>httl-script</artifactId> <version>1.0.11</version> </dependency> <dependency> <groupId>com.github.httl</groupId> <artifactId>httl-servlet</artifactId> <version>1.0.11</version> </dependency> <dependency> <groupId>com.github.httl</groupId> <artifactId>httl-springmvc</artifactId> <version>1.0.11</version> </dependency> <dependency> <groupId>com.github.httl</groupId> <artifactId>httl-struts</artifactId> <version>1.0.11</version> </dependency> <dependency> <groupId>com.github.httl</groupId> <artifactId>httl-webx</artifactId> <version>1.0.11</version> </dependency> <dependency> <groupId>com.github.httl</groupId> <artifactId>httl-jfinal</artifactId> <version>1.0.11</version> </dependency> <dependency> <groupId>com.github.httl</groupId> <artifactId>httl-nutz</artifactId> <version>1.0.11</version> </dependency> --> </ dependencies > < project > |
运行示例
将war包放到:tomcat/webapps/httl-springmvc-demo-1.0.11.war,并启动tomcat,
然后访问:http://localhost:8080/httl-springmvc-demo-1.0.11
源代仓库
可以用同样的方式,导入MVC集成示例源码。
下载主干源码:
1
2
|
git clone https://github.com/httl/httl.git cd httl |
或者,直接下载各版本Tag包,并解压:
1
2
3
|
unzip httl-1.0.11.zip -d httl-1.0.11 cd httl-1.0.11 |
编译源码:
1
|
mvn install -Dmaven.test.skip |
生成Eclipse工程描述文件:
1
|
mvn eclipse:eclipse -DdownloadSources |
导入Eclipse工程:
Eclipse -> File -> Import -> Existing Projects into Workspace -> Browse -> Finished
将.httl文件以html编辑器格式打开:
Eclipse -> Window -> Preferences -> General -> Content Types -> Text -> HTML -> Add -> *.httl
安装Maven命令行:(用于支持上面的mvn命令)
Linux:
1
2
3
|
tar zxvf apache-maven-2.2.1-bin.tar.gz export PATH=$PATH:apache-maven-2.2.1/bin |
Windows:
1
2
3
|
解压 apache-maven-2.2.1-bin.tar.gz 桌面 -> 我的电脑 -> 右键菜单 -> 系统属性 -> 高级 -> 环境变量 -> 在PATH变量中加入apache-maven-2.2.1/bin目录。 |