- // ***************** root对象的概念 ******************* //
- public void testOgnl_01() throws Exception{
- User user = new User();
- user.setUsername("张三");
- //相当于调用user.getUsername()方法
- String value = (String)Ognl.getValue("username", user);
- System.out.println(value);
- }
- public void testOgnl_02() throws Exception{
- User user = new User();
- Person p = new Person();
- p.setName("张三");
- user.setPerson(p);
- //相当于调用user.getPerson().getName()方法
- String value = (String)Ognl.getValue("person.name", user);
- System.out.println(value);
- }
- public void testOgnl_03() throws Exception{
- User user = new User();
- Person p = new Person();
- p.setName("张三");
- user.setPerson(p);
- //可以使用#root来引用根对象,相当于调用user.getPerson().getName()方法
- String value = (String)Ognl.getValue("#root.person.name", user);
- System.out.println(value);
- }
- // ***************** root对象的概念 ******************* //
- public void testOgnl_01() throws Exception{
- User user = new User();
- user.setUsername("张三");
- //相当于调用user.getUsername()方法
- String value = (String)Ognl.getValue("username", user);
- System.out.println(value);
- }
- public void testOgnl_02() throws Exception{
- User user = new User();
- Person p = new Person();
- p.setName("张三");
- user.setPerson(p);
- //相当于调用user.getPerson().getName()方法
- String value = (String)Ognl.getValue("person.name", user);
- System.out.println(value);
- }
- public void testOgnl_03() throws Exception{
- User user = new User();
- Person p = new Person();
- p.setName("张三");
- user.setPerson(p);
- //可以使用#root来引用根对象,相当于调用user.getPerson().getName()方法
- String value = (String)Ognl.getValue("#root.person.name", user);
- System.out.println(value);
- }
- // *********************** context的概念 **********************//
- public void testOgnl_04() throws Exception{
- Person p1 = new Person();
- Person p2 = new Person();
- p1.setName("张三");
- p2.setName("李四");
- Map context = new HashMap();
- context.put("p1", p1);
- context.put("p2", p2);
- String value = (String)Ognl.getValue("#p1.name + ',' + #p2.name", context, new Object());
- System.out.println(value);
- }
- public void testOgnl_05() throws Exception{
- Person p1 = new Person();
- Person p2 = new Person();
- p1.setName("张三");
- p2.setName("李四");
- Map context = new HashMap();
- context.put("p1", p1);
- context.put("p2", p2);
- User root = new User();
- root.setUsername("zhangsan");
- String value = (String)Ognl.getValue("#p1.name + ',' + #p2.name + ',' + username", context, root);
- System.out.println(value);
- }
- // *********************** context的概念 **********************//
- public void testOgnl_04() throws Exception{
- Person p1 = new Person();
- Person p2 = new Person();
- p1.setName("张三");
- p2.setName("李四");
- Map context = new HashMap();
- context.put("p1", p1);
- context.put("p2", p2);
- String value = (String)Ognl.getValue("#p1.name + ',' + #p2.name", context, new Object());
- System.out.println(value);
- }
- public void testOgnl_05() throws Exception{
- Person p1 = new Person();
- Person p2 = new Person();
- p1.setName("张三");
- p2.setName("李四");
- Map context = new HashMap();
- context.put("p1", p1);
- context.put("p2", p2);
- User root = new User();
- root.setUsername("zhangsan");
- String value = (String)Ognl.getValue("#p1.name + ',' + #p2.name + ',' + username", context, root);
- System.out.println(value);
- }
- // ******************* OGNL赋值操作 ************************//
- public void testOgnl_06() throws Exception{
- User user = new User();
- //给root对象的属性赋值,相当于调用user.setUsername()
- Ognl.setValue("username", user, "zhangsan");
- System.out.println(user.getUsername());
- }
- public void testOgnl_07() throws Exception{
- User user = new User();
- Map context = new HashMap();
- context.put("u", user);
- //给context中的对象属性赋值,相当于调用user.setUsername()
- Ognl.setValue("#u.username",context, new Object(), "zhangsan");
- System.out.println(user.getUsername());
- }
- public void testOgnl_08() throws Exception{
- User user = new User();
- Map context = new HashMap();
- context.put("u", user);
- //给context中的对象属性赋值,相当于调用user.setUsername()
- //在表达式中使用=赋值操作符来赋值
- Ognl.getValue("#u.username = '张三'",context, new Object());
- System.out.println(user.getUsername());
- }
- public void testOgnl_09() throws Exception{
- User user = new User();
- Person p = new Person();
- Map context = new HashMap();
- context.put("u", user);
- context.put("p", p);
- //给context中的对象属性赋值,相当于调用user.setUsername()
- //在表达式中使用=赋值操作符来赋值
- Ognl.getValue("#u.username = '张三',#p.name = '李四'",context, new Object());
- System.out.println(user.getUsername()+","+p.getName());
- }
- // ******************* OGNL赋值操作 ************************//
- public void testOgnl_06() throws Exception{
- User user = new User();
- //给root对象的属性赋值,相当于调用user.setUsername()
- Ognl.setValue("username", user, "zhangsan");
- System.out.println(user.getUsername());
- }
- public void testOgnl_07() throws Exception{
- User user = new User();
- Map context = new HashMap();
- context.put("u", user);
- //给context中的对象属性赋值,相当于调用user.setUsername()
- Ognl.setValue("#u.username",context, new Object(), "zhangsan");
- System.out.println(user.getUsername());
- }
- public void testOgnl_08() throws Exception{
- User user = new User();
- Map context = new HashMap();
- context.put("u", user);
- //给context中的对象属性赋值,相当于调用user.setUsername()
- //在表达式中使用=赋值操作符来赋值
- Ognl.getValue("#u.username = '张三'",context, new Object());
- System.out.println(user.getUsername());
- }
- public void testOgnl_09() throws Exception{
- User user = new User();
- Person p = new Person();
- Map context = new HashMap();
- context.put("u", user);
- context.put("p", p);
- //给context中的对象属性赋值,相当于调用user.setUsername()
- //在表达式中使用=赋值操作符来赋值
- Ognl.getValue("#u.username = '张三',#p.name = '李四'",context, new Object());
- System.out.println(user.getUsername()+","+p.getName());
- }
- //****************** 使用OGNL调用对象的方法 **********************//
- public void testOgnl_10() throws Exception{
- User user = new User();
- user.setUsername("张三");
- String value = (String)Ognl.getValue("getUsername()", user);
- System.out.println(value);
- }
- public void testOgnl_11() throws Exception{
- User user = new User();
- Ognl.getValue("setUsername('张三')", user);
- System.out.println(user.getUsername());
- }
- //****************** 使用OGNL调用对象的方法 **********************//
- public void testOgnl_10() throws Exception{
- User user = new User();
- user.setUsername("张三");
- String value = (String)Ognl.getValue("getUsername()", user);
- System.out.println(value);
- }
- public void testOgnl_11() throws Exception{
- User user = new User();
- Ognl.getValue("setUsername('张三')", user);
- System.out.println(user.getUsername());
- }
- // ********************* OGNL中的this表达式 **********************//
- public void testOgnl_14() throws Exception{
- Object root = new Object();
- Map context = new HashMap();
- List values = new ArrayList();
- for(int i=0; i<11; i++){
- values.add(i);
- }
- context.put("values", values);
- Ognl.getValue("@System@out.println(#values.size.(#this > 10 ? /"大于10/" : '不大于10'))", context, root);
- }
- public void testOgnl_15() throws Exception{
- User user = new User();
- Ognl.getValue("setUsername('ZHANGSAN')", user);
- Ognl.getValue("@System@out.println(#this.username)", user);
- }
- public void testOgnl_16() throws Exception{
- User user = new User();
- Ognl.getValue("setUsername('ZHANGSAN')", user);
- Ognl.getValue("@System@out.println(username.(#this.toLowerCase()))", user);
- }
- // ********************* OGNL中的this表达式 **********************//
- public void testOgnl_14() throws Exception{
- Object root = new Object();
- Map context = new HashMap();
- List values = new ArrayList();
- for(int i=0; i<11; i++){
- values.add(i);
- }
- context.put("values", values);
- Ognl.getValue("@System@out.println(#values.size.(#this > 10 ? /"大于10/" : '不大于10'))", context, root);
- }
- public void testOgnl_15() throws Exception{
- User user = new User();
- Ognl.getValue("setUsername('ZHANGSAN')", user);
- Ognl.getValue("@System@out.println(#this.username)", user);
- }
- public void testOgnl_16() throws Exception{
- User user = new User();
- Ognl.getValue("setUsername('ZHANGSAN')", user);
- Ognl.getValue("@System@out.println(username.(#this.toLowerCase()))", user);
- }
- // ******************* 如何把表达式的解释结果作为另外一个表达式,OGNL中括号的使用 **********************//
- public void testOgnl_17() throws Exception{
- Object root = new Object();
- Map context = new HashMap();
- User u = new User();
- u.setUsername("张三");
- context.put("u", u);
- context.put("fact", "username");
- /**
- * 1、首先把#fact表达式进行解释,得到一个值:username
- * 2、解释括号中的表达式#u,其结果是user对象
- * 3、把括号中表达式的结果作为root对象,解释在第一步中得到的结果(即把第一步的结果看成另外一个表达式)
- */
- String value = (String)Ognl.getValue("#fact(#u)", context, root);
- System.out.println(value);
- }
- public void testOgnl_18() throws Exception{
- Person person = new Person();
- Map context = new HashMap();
- User u = new User();
- u.setUsername("张三");
- context.put("u", u);
- /**
- * 相当于调用person这个根对象的fact方法,并把#u的解释结果作为参数传入此方法
- */
- String value = (String)Ognl.getValue("fact(#u)", context, person);
- System.out.println(value); //输出是 "张三,"
- }
- public void testOgnl_19() throws Exception{
- Person person = new Person();
- Map context = new HashMap();
- User u = new User();
- u.setUsername("张三");
- context.put("u", u);
- /**
- * 1、先计算表达式fact,得到结果是:username
- * 2、解释括号中的表达式#u,其结果是user对象
- * 3、把括号中表达式的结果作为root对象,解释在第一步中得到的结果(即把第一步的结果看成另外一个表达式)
- */
- String value = (String)Ognl.getValue("(fact)(#u)", context, person);
- System.out.println(value); //输出"张三"
- }
- // ******************* 如何把表达式的解释结果作为另外一个表达式,OGNL中括号的使用 **********************//
- public void testOgnl_17() throws Exception{
- Object root = new Object();
- Map context = new HashMap();
- User u = new User();
- u.setUsername("张三");
- context.put("u", u);
- context.put("fact", "username");
- /**
- * 1、首先把#fact表达式进行解释,得到一个值:username
- * 2、解释括号中的表达式#u,其结果是user对象
- * 3、把括号中表达式的结果作为root对象,解释在第一步中得到的结果(即把第一步的结果看成另外一个表达式)
- */
- String value = (String)Ognl.getValue("#fact(#u)", context, root);
- System.out.println(value);
- }
- public void testOgnl_18() throws Exception{
- Person person = new Person();
- Map context = new HashMap();
- User u = new User();
- u.setUsername("张三");
- context.put("u", u);
- /**
- * 相当于调用person这个根对象的fact方法,并把#u的解释结果作为参数传入此方法
- */
- String value = (String)Ognl.getValue("fact(#u)", context, person);
- System.out.println(value); //输出是 "张三,"
- }
- public void testOgnl_19() throws Exception{
- Person person = new Person();
- Map context = new HashMap();
- User u = new User();
- u.setUsername("张三");
- context.put("u", u);
- /**
- * 1、先计算表达式fact,得到结果是:username
- * 2、解释括号中的表达式#u,其结果是user对象
- * 3、把括号中表达式的结果作为root对象,解释在第一步中得到的结果(即把第一步的结果看成另外一个表达式)
- */
- String value = (String)Ognl.getValue("(fact)(#u)", context, person);
- System.out.println(value); //输出"张三"
- }
- // ********************* OGNL访问集合元素 **************************//
- public void testOgnl_20() throws Exception{
- Object root = new Object();
- Map context = new HashMap();
- //用OGNL创建List对象
- List listvalue = (List)Ognl.getValue("{123,'kdjfk','oooo'}", context, root);
- context.put("listvalue", listvalue);
- //用OGNL创建数组
- int[] intarray= (int[])Ognl.getValue("new int[]{23,45,67}", context, root);
- context.put("intarray", intarray);
- //用OGNL创建Map对象
- Map mapvalue = (Map)Ognl.getValue("#{'listvalue':#listvalue,'intarray':#intarray}", context, root);
- context.put("mapvalue", mapvalue);
- Ognl.getValue("@System@out.println(#listvalue[0])", context, root);
- Ognl.getValue("@System@out.println(#intarray[1])", context, root);
- Ognl.getValue("@System@out.println(#mapvalue['intarray'][2])", context, root);
- Ognl.getValue("@System@out.println(#mapvalue.intarray[0])", context, root);
- }
相关推荐
微信小程序 备忘录 (源码)微信小程序 备忘录 (源码)微信小程序 备忘录 (源码)微信小程序 备忘录 (源码)微信小程序 备忘录 (源码)微信小程序 备忘录 (源码)微信小程序 备忘录 (源码)微信小程序 备忘录 (源码)微信小...
小程序源码 备忘录 (代码+截图)小程序源码 备忘录 (代码+截图)小程序源码 备忘录 (代码+截图)小程序源码 备忘录 (代码+截图)小程序源码 备忘录 (代码+截图)小程序源码 备忘录 (代码+截图)小程序源码 备忘录 (代码+...
微信小程序源码 备忘录(学习版)微信小程序源码 备忘录(学习版)微信小程序源码 备忘录(学习版)微信小程序源码 备忘录(学习版)微信小程序源码 备忘录(学习版)微信小程序源码 备忘录(学习版)微信小程序源码 备忘录(学习...
微信小程序 小工具类 备忘录 (源代码+截图)微信小程序 小工具类 备忘录 (源代码+截图)微信小程序 小工具类 备忘录 (源代码+截图)微信小程序 小工具类 备忘录 (源代码+截图)微信小程序 小工具类 备忘录 (源...
设计和实现一个类似个人备忘录的 Android APP ,数据库采用 SQLite (也可以直接访问 Web 端 MySQL 数据库、或提供 Web 接口访问 MySQL 数据库)。 1.用户注册和登录(这类 APP 一般面对个人,用户不需要分类别); ...
微信小程序备忘录,备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录备忘录...
包括了备忘录程序的基本功能,添加备忘信息,时间到了会自动提醒
备忘录模式的示例代码和文档,学习备忘录模式的参考资料。
可以放在桌面的备忘录,很实用,大家下了试用才知道。。。。
项目工程备忘录
用java实现备忘时钟,适合初学者,用java实现备忘时钟,适合初学者,
Android 备忘录源码.rar
android备忘录app源码
微信小程序实现的简易备忘录,可以记录代办事项,可以标记事项是否完成 微信小程序实现的简易备忘录,可以记录代办事项,可以标记事项是否完成 微信小程序实现的简易备忘录,可以记录代办事项,可以标记事项是否完成...
十年了,再次提交自己的一个小软件。基于MFC和ACCESS数据库,桌面小软件,用于备忘。记录平时自己怕忘记的事情,占资源很小,免费。压缩包里附带源文件增加窗口透明性,最小化状态栏等等。
效能备忘录是一款专业的备忘录和笔记本软件。软件可以实现美观易用、功能强大的编辑器来实现用户所需的各种备忘记事功能,来实现多篇备忘、笔记和文档信息等用途。软件界面美观简洁、简单全面、实用方便,无需培训,...
微信小程序推荐demo:备忘录:适用1028版本(源代码+截图)微信小程序推荐demo:备忘录:适用1028版本(源代码+截图)微信小程序推荐demo:备忘录:适用1028版本(源代码+截图)微信小程序推荐demo:备忘录:适用1028版本...
毕业设计基于JavaWeb实现的一个备忘录系统项目源码。难度适中,新手自己可操作 备忘录 介绍 后端部分基于Servlet、Jdbc实现. 前端部分基于Layui、jqury实现。 一个简单的前后端分离Demo,前后端交互JSON数据格式 ...
微信小程序Demo:备忘录
定时提醒、备忘提醒、支持邮件短信提醒、免费的支持云功能