freemark 全部資料 以及相關(guān)JAR包 還有具體代碼實(shí)現(xiàn)
目錄:
├─freemarker (1).doc 25.50KB
├─FreeMarker (1).ppt 631.00KB
├─freeMarker.doc 44.50KB
├─freemarker.docx 89.77KB
├─freemarker.ppt 135.00KB
├─Freemarker_-_幾個(gè)比較實(shí)用的例子.txt 1.62KB
├─freemarker_中文參考手冊(cè).doc 195.50KB
├─FreeMarker在struts2.1.8_JAVA_web中的應(yīng)用實(shí)例.txt 13.27KB
├─FreeMarker學(xué)習(xí)分享.ppt 494.50KB
├─freemarker學(xué)習(xí)文檔.doc 216.50KB
├─Freemarker教程_中文版.pdf 297.22KB
├─FreeMarker標(biāo)簽使用.doc 35.00KB
├─freemarker根據(jù)模版生成文件使用例子.doc 104.50KB
└─freemarker語(yǔ)法帶小例子.doc 83.50KB
教程:
第一步 配置
<result name="freemarker" type="freemarker">/duan.ftl</result>
第二部 action
/**
* freemarker.ftl查詢(xún)用戶(hù)用
* @return
*/
public String ecshopSelect()
{
// System.out.println(login.getUsername());
List list=ecshopBiz.doUSer();
request.setAttribute("userList", list);
goodsMap.put(1, "段");
goodsMap.put(2, "光");
goodsMap.put(3, "強(qiáng)");
request.setAttribute("map", goodsMap);
return "freemarker";
}
第三部biz
public List doUSer()
{
String sql="";
boolean b=false;
List list=null;
try {
sql="select id,username,password,email from ecshop_login";
list=baseDaoBySql.getList(sql, null, LoginEntity.class);
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
第四 頁(yè)面
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'freemarker.ftl' starting page</title>
</head>
<body>
<hr>
用戶(hù)列表1<br>
<table>
<th>id</th> <th>用戶(hù)名</th> <th>密碼</th> <th>郵箱</th>
<#if userList?exists>
<#list userList as x>
<tr>
<td>${x.id}<td><td>${x.username}<td><td>${x.password}<td><td>${x.email}<td>
</tr>
</#list>
</#if>
</table>
<hr>
獲取整數(shù)部分<br>
<#assign x=9>
${(x/2)?int}
${userList?size}
<hr>
<select>
<#list map?keys as testKey>
<option value="${testKey}">
${map.get(testKey)}
</option><br>
</#list>
</select>
<hr>
<select>
<#list map.keySet() as testKey>
<option value="${testKey}">
${map.get(testKey)}
</option><br>
</#list>
</select>
</body>
</html>