http://grepcode.com/snapshot/repo1.maven.org/maven2/ognl/ognl/2.7.3/java
在这个页面中能够找到它所依赖的jar包:maven
下载便可.ide
- /**
- * Copyright (C) Skywares Information Technology, LTD.
- * All Rights Reserved.
- *
- * TestOgnl.java created on 2013-1-14 下午4:39:03 by hubert.guo
- */
- package com.skywares.ognl;
- import ognl.Ognl;
- import ognl.OgnlException;
- /**
- * <pre>
- * Description
- * @TODO file description here
- *
- * @author hubert.guo
- * @since 1.0
- *
- * Change History
- * Date Modifier DESC.
- * 2013-1-14 hubert.guo Initial version.
- * </pre>
- */
- public class TestOgnl
- {
- /**
- * @param args
- */
- public static void main(String[] args)
- {
- try
- {
- Object result = Ognl.getValue("userName", new User("zhangSan",12));
- System.out.println(result.toString());
- }
- catch (OgnlException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- class User
- {
- private String userName;
- private Integer age;
- /**
- *
- */
- public User(String userName, Integer age)
- {
- // TODO Auto-generated constructor stub
- this.userName = userName;
- this.age = age;
- }
- /**
- * @return the userName
- */
- public String getUserName()
- {
- return userName;
- }
- /**
- * @param userName
- * the userName to set
- */
- public void setUserName(String userName)
- {
- this.userName = userName;
- }
- /**
- * @return the age
- */
- public Integer getAge()
- {
- return age;
- }
- /**
- * @param age
- * the age to set
- */
- public void setAge(Integer age)
- {
- this.age = age;
- }
- }
并在35行设定断点,关联源代码,以调试方式开始了解OGNL表达式的实现方式和原理.this