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