您的位置:首页 > 其它

freemarker使用bean类的一个实例

2008-01-30 09:33 381 查看

<html>[BR]


<head>[BR]


<title>Welcome!</title>[BR]


</head>[BR]


<body>[BR]


<#-- Greet the user with his/her name -->[BR]




<h1>Welcome $...{name}!</h1>[BR]


<p>We have these animals:[BR]


<ul>[BR]


<#list users as being>[BR]




<li>$...{being.name} for $...{being.price} Euros[BR]


</#list>[BR]


</ul>[BR]


</body>[BR]


</html>




public class User ...{


private String name;




private String price;






public User(String name, String price) ...{


this.name = name;


this.price = price;


}






public String getName() ...{


return name;


}






public void setName(String name) ...{


this.name = name;


}






public String getPrice() ...{


return price;


}






public void setPrice(String price) ...{


this.price = price;


}


}




Map<String, Object> root = new HashMap<String, Object>();


List<User> list = new ArrayList<User>();


list.add(new User("cat", "3.2"));


list.add(new User("test1", "1.1"));


root.put("users", list);


Map<String, Object> map = new HashMap<String, Object>();


root.put("name", "aa");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐