首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

转: struts 二专用表达式(10)上

2012-07-01 
转: struts 2专用表达式(10)上package?ch8import?java.util.Date//团队类public?class?Team?{????//?团

转: struts 2专用表达式(10)上

package?ch8;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上import?java.util.Date;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上//团队类
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上public?class?Team?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????//?团队名称
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????private?String?teamname;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????//?定义团队人员属性
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????private?Person?person;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????//?团队人数
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????private?int?personnum;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????//属性的getter和setter方法
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?String?getTeamname()?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????return?teamname;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?void?setTeamname(String?teamname)?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????this.teamname?=?teamname;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?Person?getPerson()?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????return?person;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?void?setPerson(Person?person)?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????this.person?=?person;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?int?getPersonnum()?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????return?personnum;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?void?setPersonnum(int?personnum)?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????this.personnum?=?personnum;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上//?定义人员类
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上class?Person?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????//?姓名
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????private?String?name;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????//?年龄
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????private?int?age;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????//?人员出生日期
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????private?Date?birthday;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????//属性的getter和setter方法
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?String?getName()?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????return?name;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public??void?setName(String?name)?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????this.name?=?name;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?int?getAge()?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????return?age;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?void?setAge(int?age)?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????this.age?=?age;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?Date?getBirthday()?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????return?birthday;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????public?void?setBirthday(Date?birthday)?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????this.birthday?=?birthday;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上

package?ch8;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上import?java.util.HashMap;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上import?java.util.Map;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上import?ognl.Ognl;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上import?ognl.OgnlException;
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上public?class?TestOGNL?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????public?static?void?main(String[]?args)?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????//?定义一个Map对象
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????Map?m?=?new?HashMap();
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????//定义一个Team对象
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????Team?team1?=?new?Team();
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????team1.setTeamname("团队1");
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????//定义一个Person对象
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????Person?person1?=?new?Person();
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????person1.setName("pla1");
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????//添加team元素
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????team1.setPerson(person1);
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????//定义一个Team对象
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????Team?team2?=?new?Team();
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????team2.setTeamname("团队2");
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????//定义一个Person对象
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????Person?person2?=?new?Person();
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????person2.setName("pla2");
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????//添加team元素
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????team2.setPerson(person2);
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????//添加Map元素
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????m.put("team1",?team1);
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????m.put("team2",?team2);
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????try?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????????System.out.println(Ognl.getValue("team1.teamname",?m));
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????????System.out.println(Ognl.getValue("team2.person.name",?m));
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????????System.out.println(Ognl.getValue("teamname",?team2));
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????????System.out.println(Ognl.getValue("person.name",?team2));
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????}?catch?(OgnlException?e)?{
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上????}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上}
转: struts 二专用表达式(10)上
转: struts 二专用表达式(10)上

OGNL可以使用非常简单的表达式来访问多层嵌套属性,为开发者提供了一个有力的工具。

?

热点排行