我用的是velocity1.7版本,要在web使用velocity引擎,必须把它的velocity-1.7.jar包放在tomcat(整个tomcat的多个项目可以共用)或者webroot下的web-inf下(只有自己可以用);当然用到servle,就要引入tomcat的servlet-api.jar包,在引入java通用包:rt.jar环境就配置好了

下面写入html(velocity默认的后缀名是vm,我习惯用html):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>

<body>
#set( $this = "Velocity")

$this is so great!
<br>
#foreach( $name in $list )
$name 真的太奇妙啦!
<br/>
#end

#set( $condition = true)

#if ($condition)
您选择的是1!
#else
您选择的是0!
#end
<br>
我的主页.
<br>

</body>
</html>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-09-18
猜你喜欢
  • 2021-09-28
  • 2022-12-23
  • 2021-06-09
  • 2021-09-28
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
相关资源
相似解决方案