浙江省高等学校教师教育理论培训

微信搜索“教师资格证岗前培训”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Ok, lets start off with some easy examples. These examples really do not even touch on the basics of correct design. However, they still make good examples because correct design is often harder than showing a simple example. We will show better examples further along in this essay.

For the first example, we show that there are two different approaches of doing the same exact thing using both JSP and Velocity. This is an example of printing out a parameter with JSP:

<html>
<head><title>Hello</title></head>
<body>
<h1>
<%
if (request.getParameter("name") == null) {
   out.println("Hello World");
}
else {
  out.println("Hello, " + request.getParameter("name"));
}
%>
</h1>
</body></html>

This is an example of doing the same thing with Velocity:

<html>
<head><title>Hello</title></head>
<body>
<h1>
#if ($request.getParameter("name") == null)
   Hello World
#else
   Hello, $request.getParameter("name")
#end
</h1>
</body></html>
posted on 2012-07-07 15:03  lexus  阅读(253)  评论(0编辑  收藏  举报