一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|

服務(wù)器之家 - 編程語(yǔ)言 - JAVA教程 - 通過(guò)實(shí)例深入學(xué)習(xí)Java的Struts框架中的OGNL表達(dá)式使用

通過(guò)實(shí)例深入學(xué)習(xí)Java的Struts框架中的OGNL表達(dá)式使用

2020-03-03 20:04浮云中的毛驢 JAVA教程

這篇文章主要通過(guò)實(shí)例介紹了Java的Strus框架中的OGNL表達(dá)式使用,Struts框架是Java的SSH三大web開(kāi)發(fā)框架之一,需要的朋友可以參考下

Struts 2默認(rèn)的表達(dá)式語(yǔ)言是OGNL,原因是它相對(duì)其它表達(dá)式語(yǔ)言具有下面幾大優(yōu)勢(shì):
1. 支持對(duì)象方法調(diào)用,如xxx.doSomeSpecial();
2. 支持類靜態(tài)的方法調(diào)用和值訪問(wèn),表達(dá)式的格式為@[類全名(包括包路徑)]@[方法名 | 值名],例如:@java.lang.String@format('foo %s', 'bar')或@tutorial.MyConstant@APP_NAME;
3. 支持賦值操作和表達(dá)式串聯(lián),如price=100, discount=0.8, calculatePrice(),這個(gè)表達(dá)式會(huì)返回80;
4. 訪問(wèn)OGNL上下文(OGNL context)和ActionContext;
5. 操作集合對(duì)象。
下面我們來(lái)看OGNL使用的幾個(gè)例子:

示例:上下文環(huán)境中使用OGNL

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
public class OGNL1
{
  public static void main(String[] args)
  {
    /* 創(chuàng)建一個(gè)上下文Context對(duì)象,它是用保存多個(gè)對(duì)象一個(gè)環(huán)境 對(duì)象 */
    Map<String , Object> context = new HashMap<String , Object>();
 
    Person person1 = new Person();
    person1.setName("zhangsan");
     
    Person person2 = new Person();
    person2.setName("lisi");
 
    Person person3 = new Person();
    person3.setName("wangwu");
 
    /* person4不放入到上下文環(huán)境中 */
    Person person4 = new Person();
    person4.setName("zhaoliu");
 
    /* 將person1、person2、person3添加到環(huán)境中(上下文中) */
    context.put("person1", person1);
    context.put("person2", person2);
    context.put("person3", person3);
 
    try
    {
      /* 獲取根對(duì)象的"name"屬性值 */
      Object value = Ognl.getValue("name", context, person2);
      System.out.println("ognl expression \"name\" evaluation is : " + value);
 
      /* 獲取根對(duì)象的"name"屬性值 */
      Object value2 = Ognl.getValue("#person2.name", context, person2);
      System.out.println("ognl expression \"#person2.name\" evaluation is : " + value2);
 
      /* 獲取person1對(duì)象的"name"屬性值 */
      Object value3 = Ognl.getValue("#person1.name", context, person2);
      System.out.println("ognl expression \"#person1.name\" evaluation is : " + value3);
 
      /* 將person4指定為root對(duì)象,獲取person4對(duì)象的"name"屬性,注意person4對(duì)象不在上下文中 */
      Object value4 = Ognl.getValue("name", context, person4);
      System.out.println("ognl expression \"name\" evaluation is : " + value4);
 
      /* 將person4指定為root對(duì)象,獲取person4對(duì)象的"name"屬性,注意person4對(duì)象不在上下文中 */
      Object value5 = Ognl.getValue("#person4.name", context, person4);
      System.out.println("ognl expression \"person4.name\" evaluation is : " + value5);
 
      /* 獲取person4對(duì)象的"name"屬性,注意person4對(duì)象不在上下文中 */
      // Object value6 = Ognl.getValue("#person4.name", context, person2);
      // System.out.println("ognl expression \"#person4.name\" evaluation is : " + value6);
 
    }
    catch (OgnlException e)
    {
      e.printStackTrace();
    }
  }
}
 
class Person
{
  private String name;
 
  public String getName()
  {
    return name;
  }
 
  public void setName(String name)
  {
    this.name = name;
  }
}

控制臺(tái)輸出:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
ognl expression "name" evaluation is : lisi
ognl expression "#person2.name" evaluation is : lisi
ognl expression "#person1.name" evaluation is : zhangsan
ognl expression "name" evaluation is : zhaoliu
ognl.OgnlException: source is null for getProperty(null, "name")
  at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2296)
  at ognl.ASTProperty.getValueBody(ASTProperty.java:114)
  at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
  at ognl.SimpleNode.getValue(SimpleNode.java:258)
  at ognl.ASTChain.getValueBody(ASTChain.java:141)
  at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
  at ognl.SimpleNode.getValue(SimpleNode.java:258)
  at ognl.Ognl.getValue(Ognl.java:494)
  at ognl.Ognl.getValue(Ognl.java:596)
  at ognl.Ognl.getValue(Ognl.java:566)
  at com.beliefbetrayal.ognl.OGNL1.main(OGNL1.java:53)

對(duì)于使用上下文的OGNL,若不指定從哪一個(gè)對(duì)象中查找"name"屬性,則OGNL直接從根對(duì)象(root)查找,若指定查找對(duì)象(使用'#'號(hào)指定,如#person1),則從指定的對(duì)象中查找,若指定對(duì)象不在上下文中則會(huì)拋出異常,換句話說(shuō)就是是#person1.name形式指定查找對(duì)象則必須要保證指定對(duì)象在上下文環(huán)境中。

示例:使用OGNL調(diào)用方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
public class OGNL2
{
  public static void main(String[] args)
  {
    /* OGNL提供的一個(gè)上下文類,它實(shí)現(xiàn)了Map接口 */
    OgnlContext context = new OgnlContext();
 
    People people1 = new People();
    people1.setName("zhangsan");
 
    People people2 = new People();
    people2.setName("lisi");
 
    People people3 = new People();
    people3.setName("wangwu");
 
    context.put("people1", people1);
    context.put("people2", people2);
    context.put("people3", people3);
     
    context.setRoot(people1);
 
    try
    {
      /* 調(diào)用 成員方法 */
      Object value = Ognl.getValue("name.length()", context, context.getRoot());
      System.out.println("people1 name length is :" + value);
       
      Object upperCase = Ognl.getValue("#people2.name.toUpperCase()", context, context.getRoot());
      System.out.println("people2 name upperCase is :" + upperCase);
 
      Object invokeWithArgs = Ognl.getValue("name.charAt(5)", context, context.getRoot());
      System.out.println("people1 name.charAt(5) is :" + invokeWithArgs);
 
      /* 調(diào)用靜態(tài)方法 */
      Object min = Ognl.getValue("@java.lang.Math@min(4,10)", context, context.getRoot());
      System.out.println("min(4,10) is :" + min);
 
      /* 調(diào)用靜態(tài)變量 */
      Object e = Ognl.getValue("@java.lang.Math@E", context, context.getRoot());
      System.out.println("E is :" + e);
    }
    catch (OgnlException e)
    {
      e.printStackTrace();
    }
  }
}
 
class People
{
  private String name;
 
  public String getName()
  {
    return name;
  }
 
  public void setName(String name)
  {
    this.name = name;
  }
}

控制臺(tái)輸出:

?
1
2
3
4
5
people1 name length is :8
people2 name upperCase is :LISI
people1 name.charAt(5) is :s
min(4,10) is :4
E is :2.718281828459045

使用OGNL調(diào)用方法也十分簡(jiǎn)單,對(duì)于成員方法調(diào)用,只需要給出方法的名稱+(),若有參數(shù),直接寫在括號(hào)內(nèi),與一般調(diào)用Java方法一致。對(duì)于靜態(tài)方法的調(diào)用,需要使用如下格式:@ClassName@method,對(duì)于靜態(tài)變量需要使用如下格式:@ClassName@field。

示例:使用OGNL操作集合

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
public class OGNL3
{
  public static void main(String[] args) throws Exception
  {
    OgnlContext context = new OgnlContext();
     
    Classroom classroom = new Classroom();
    classroom.getStudents().add("zhangsan");
    classroom.getStudents().add("lisi");
    classroom.getStudents().add("wangwu");
    classroom.getStudents().add("zhaoliu");
    classroom.getStudents().add("qianqi");
     
    Student student = new Student();
    student.getContactWays().put("homeNumber", "110");
    student.getContactWays().put("companyNumber", "119");
    student.getContactWays().put("mobilePhone", "112");
     
    context.put("classroom", classroom);
    context.put("student", student);
    context.setRoot(classroom);
 
    /* 獲得classroom的students集合 */
    Object collection = Ognl.getValue("students", context, context.getRoot());
    System.out.println("students collection is :" + collection);
 
    /* 獲得classroom的students集合 */
    Object firstStudent = Ognl.getValue("students[0]", context, context.getRoot());
    System.out.println("first student is : " + firstStudent);
 
    /* 調(diào)用集合的方法 */
    Object size = Ognl.getValue("students.size()", context, context.getRoot());
    System.out.println("students collection size is :" + size);
 
    System.out.println("--------------------------飄逸的分割線--------------------------");
     
    Object mapCollection = Ognl.getValue("#student.contactWays", context, context.getRoot());
    System.out.println("mapCollection is :" + mapCollection);
 
    Object firstElement = Ognl.getValue("#student.contactWays['homeNumber']", context, context.getRoot());
    System.out.println("the first element of contactWays is :" + firstElement);
 
    System.out.println("--------------------------飄逸的分割線--------------------------");
 
    /* 創(chuàng)建集合 */
    Object createCollection = Ognl.getValue("{'aa','bb','cc','dd'}", context, context.getRoot());
    System.out.println(createCollection);
 
    /* 創(chuàng)建Map集合 */
    Object createMapCollection = Ognl.getValue("#{'key1':'value1','key2':'value2'}", context, context.getRoot());
    System.out.println(createMapCollection);
 
  }
}
 
class Classroom
{
  private List<String> students = new ArrayList<String>();
 
  public List<String> getStudents()
  {
    return students;
  }
 
  public void setStudents(List<String> students)
  {
    this.students = students;
  }
}
 
class Student
{
  private Map<String , Object> contactWays = new HashMap<String , Object>();
 
  public Map<String , Object> getContactWays()
  {
    return contactWays;
  }
 
  public void setContactWays(Map<String , Object> contactWays)
  {
    this.contactWays = contactWays;
  }
}

控制臺(tái)的輸出:

?
1
2
3
4
5
6
7
8
9
students collection is :[zhangsan, lisi, wangwu, zhaoliu, qianqi]
first student is : zhangsan
students collection size is :5
--------------------------飄逸的分割線--------------------------
mapCollection is :{homeNumber=110, mobilePhone=112, companyNumber=119}
the first element of contactWays is :110
--------------------------飄逸的分割線--------------------------
[aa, bb, cc, dd]
{key1=value1, key2=value2}

OGNL不僅可以操作集合對(duì)象,還可以創(chuàng)建集合對(duì)象,對(duì)集合操作與對(duì)屬性的操作沒(méi)什么不同,需要注意的是OGNL認(rèn)為L(zhǎng)ist與Array是一樣的。使用OGNL創(chuàng)建List集合時(shí)使用{},創(chuàng)建Map對(duì)象時(shí)使用#{}。

示例:使用OGNL過(guò)濾集合與投影集合

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
public class OGNL4
{
  public static void main(String[] args) throws Exception
  {
    OgnlContext context = new OgnlContext();
 
    Humen humen = new Humen();
    humen.setName("qiuyi");
    humen.setSex("n");
    humen.setAge(22);
    humen.getFriends().add(new Humen("zhangsan" , "n" , 22));
    humen.getFriends().add(new Humen("lisi" , "f" , 21));
    humen.getFriends().add(new Humen("wangwu" , "n" , 23));
    humen.getFriends().add(new Humen("zhaoliu" , "n" , 22));
    humen.getFriends().add(new Humen("qianqi" , "n" , 22));
    humen.getFriends().add(new Humen("sunba" , "f" , 20));
    humen.getFriends().add(new Humen("yangqiu" , "f" , 25));
     
    context.put("humen", humen);
    context.setRoot(humen);
 
    /* OGNL過(guò)濾集合的語(yǔ)法為:collection.{? expression} */
    Object filterCollection = Ognl.getValue("friends.{? #this.name.length() > 7}", context, context.getRoot());
    System.out.println("filterCollection is :" + filterCollection);
 
    System.out.println("--------------------------飄逸的分割線--------------------------");
 
    /* OGNL投影集合的語(yǔ)法為:collection.{expression} */
    Object projectionCollection = Ognl.getValue("friends.{name}", context, context.getRoot());
    System.out.println("projectionCollection is :" + projectionCollection);
  }
}
 
class Humen
{
  private String name;
  private String sex;
  private int age;
  private List<Humen> friends = new ArrayList<Humen>();
 
  public Humen()
  {
 
  }
 
  public Humen(String name , String sex , int age)
  {
    this.name = name;
    this.sex = sex;
    this.age = age;
  }
 
  public String getName()
  {
    return name;
  }
 
  public void setName(String name)
  {
    this.name = name;
  }
 
  public String getSex()
  {
    return sex;
  }
 
  public void setSex(String sex)
  {
    this.sex = sex;
  }
 
  public int getAge()
  {
    return age;
  }
 
  public void setAge(int age)
  {
    this.age = age;
  }
 
  public List<Humen> getFriends()
  {
    return friends;
  }
 
  public void setFriends(List<Humen> friends)
  {
    this.friends = friends;
  }
 
  @Override
  public String toString()
  {
    return "Humen [name=" + name + ", sex=" + sex + ", age=" + age + "]";
  }
}

控制臺(tái)輸出:

?
1
2
3
filterCollection is :[Humen [name=zhangsan, sex=n, age=22]]
--------------------------飄逸的分割線--------------------------
projectionCollection is :[zhangsan, lisi, wangwu, zhaoliu, qianqi, sunba, yangqiu]

OGNL可以對(duì)集合進(jìn)行過(guò)濾與投影操作,過(guò)濾的語(yǔ)法為collection.{? expression},其中使用"#this"表示集合當(dāng)前對(duì)象(可以與for-each循環(huán)比較)。投影的語(yǔ)法為collection.{expression}。投影和過(guò)濾可以看做是數(shù)據(jù)庫(kù)中對(duì)表取列和取行的操作。

一些常見(jiàn)問(wèn)題
平時(shí)使用Struts2標(biāo)簽時(shí)會(huì)出現(xiàn)一些很奇特的問(wèn)題,對(duì)于OGNL不了解的人可能對(duì)問(wèn)題的出現(xiàn)無(wú)能為力或者就算解決了問(wèn)題也不知道是如何解決的。下面總結(jié)一些使用Struts2標(biāo)簽容易出現(xiàn)的困惑:

問(wèn)題一:#,%{},$符號(hào)

在Struts2標(biāo)簽屬性中經(jīng)常會(huì)出現(xiàn)"#"或者"%{}"的符號(hào)出現(xiàn),通過(guò)上面OGNL表達(dá)式基礎(chǔ)的介紹,知道了OGNL上下文中有且僅有一個(gè)根對(duì)象。Struts2為我們定義了許多明明對(duì)象,他們分別是"ValueStack","Parameters","Session","Request", "Appliction","Attr",其中"ValueStack"被設(shè)置為上下文的根對(duì)象。訪問(wèn)非根對(duì)象必須加上"#"號(hào),這就是出現(xiàn)"#"的原因。Struts2中的標(biāo)的處理類,并不是所有都將標(biāo)簽的屬性作為OGNL表達(dá)式來(lái)看待,有時(shí)候我們需要設(shè)置動(dòng)態(tài)地值,則必須告訴標(biāo)簽的處理類該字符串按照OGNL表達(dá)式來(lái)處理,%{}符號(hào)的作用就是告訴標(biāo)簽的處理類將它包含的字符串按照OGNL表達(dá)式處理。 "$"符號(hào)用于XML文件中用于獲取動(dòng)態(tài)值,與%{}作用類似。

問(wèn)題二:%{}符號(hào)的影響

Struts2的標(biāo)簽幾十幾百個(gè),要記住哪一個(gè)標(biāo)簽的處理類將標(biāo)簽的屬性作為OGNL表達(dá)式是一件很困難的事情,在不清楚處理類的處理方式時(shí)怎么辦,%{}對(duì)于標(biāo)簽處理類來(lái)說(shuō),若處理類將屬性值作為普通字符串則%{}符號(hào)包含的字符串當(dāng)做OGNL表達(dá)式,若處理類將屬性值作為OGNL表達(dá)式來(lái)處理,則直接忽略%{}符號(hào)。換句話說(shuō),不清楚處理方式的話,可以都使用%{}符號(hào)。

問(wèn)題三:標(biāo)簽是如何獲得數(shù)據(jù)

下面是ValueStack的官方描述:

ValueStack allows multiple beans to be pushed in and dynamic EL expressions to be evaluated against it. When evaluating an expression, the stack will be searched down the stack, from the latest objects pushed in to the earliest, looking for a bean with a getter or setter for the given property or a method of the given name (depending on the expression being evaluated).

大致意思:ValueStack允許保存多個(gè)bean(也就是Action),并且可以使用表達(dá)式語(yǔ)言獲得他們。當(dāng)評(píng)估一個(gè)表達(dá)式,ValueStack將會(huì)從棧頂?shù)綏5椎姆较虮凰阉饕槐椋瑢?duì)于給定的屬性名稱尋找bean的getter或setter方法或?qū)ふ医o定的方法。

 

每當(dāng)一個(gè)請(qǐng)求到達(dá)Action時(shí),Struts2會(huì)將Action對(duì)象推入ValueStack中。

?
1
2
3
4
5
<body> 
  username:<s:property value="username"/><br />
  -------------------詭異的分割線-------------------<br />
  username:<%= ((HelloWorldAction)ActionContext.getContext().getValueStack().peek()).getUsername() %><br />
 </body>

頁(yè)面顯示結(jié)果:

?
1
2
3
username:zhangsan
-------------------詭異的分割線-------------------
username:zhangsan

可以看到標(biāo)簽取值與用Java代碼取值的結(jié)果相同,明顯標(biāo)簽的取值方式更簡(jiǎn)練簡(jiǎn)潔。OGNL表達(dá)式"username"表示了從根對(duì)象ValueStack中取出屬性u(píng)sername的值。它會(huì)從棧頂?shù)綏5妆闅vValueStack,直到找某一個(gè)Action中的"username"屬性。


總結(jié)OGNL的使用方法:

1.訪問(wèn)屬性
名字屬性獲取:

?
1
<s:property value="user.username"/><br>

地址屬性獲取:

?
1
<s:property value="user.address.addr"/><br>

2.訪問(wèn)方法
調(diào)用值棧中對(duì)象的普通方法:

?
1
<s:property value="user.get()"/><br>

3.訪問(wèn)靜態(tài)屬性和方法
調(diào)用Action中的靜態(tài)方法:

?
1
<s:property value="@struts.action.LoginAction@get()"/>

調(diào)用JDK中的類的靜態(tài)方法:

?
1
<s:property value="@java.lang.Math@floor(44.56)"/><br>

調(diào)用JDK中的類的靜態(tài)方法(同上):

?
1
<s:property value="@@floor(44.56)"/><br>

調(diào)用JDK中的類的靜態(tài)方法:

?
1
<s:property value="@java.util.Calendar@getInstance()"/><br>

調(diào)用普通類中的靜態(tài)屬性:

?
1
<s:property value="@struts.vo.Address@TIPS"/><br>

訪問(wèn)構(gòu)造方法
調(diào)用普通類的構(gòu)造方法: 

?
1
<s:property value="new struts.vo.Student('李曉紅' , '美女' , 3 , 25).username"/>

 

4.訪問(wèn)數(shù)組
獲取List:

?
1
<s:property value="testList"/><br>

獲取List中的某一個(gè)元素(可以使用類似于數(shù)組中的下標(biāo)獲取List中的內(nèi)容):

?
1
<s:property value="testList[0]"/><br>

獲取Set:

?
1
<s:property value="testSet"/><br>

獲取Set中的某一個(gè)元素(Set由于沒(méi)有順序,所以不能使用下標(biāo)獲取數(shù)據(jù)):

?
1
<s:property value="testSet[0]"/><br> ×

獲取Map:

?
1
<s:property value="testMap"/><br>

獲取Map中所有的鍵:

?
1
<s:property value="testMap.keys"/><br>

獲取Map中所有的值:

?
1
<s:property value="testMap.values"/><br>

獲取Map中的某一個(gè)元素(可以使用類似于數(shù)組中的下標(biāo)獲取List中的內(nèi)容):

?
1
<s:property value="testMap['m1']"/><br>

獲取List的大小: 

?
1
<s:property value="testSet.size"/><br>

 

5.訪問(wèn)集合 – 投影、選擇(? ^ $)
利用選擇獲取List中成績(jī)及格的對(duì)象:<s:property value="stus.{?#this.grade>=60}"/><br>

利用選擇獲取List中成績(jī)及格的對(duì)象的username:

?
1
<s:property value="stus.{?#this.grade>=60}.{username}"/><br>

利用選擇獲取List中成績(jī)及格的第一個(gè)對(duì)象的username:

?
1
<s:property value="stus.{?#this.grade>=60}.{username}[0]"/><br>

利用選擇獲取List中成績(jī)及格的第一個(gè)對(duì)象的username:

?
1
<s:property value="stus.{^#this.grade>=60}.{username}"/><br>

利用選擇獲取List中成績(jī)及格的最后一個(gè)對(duì)象的username:

?
1
<s:property value="stus.{$#this.grade>=60}.{username}"/><br>

利用選擇獲取List中成績(jī)及格的第一個(gè)對(duì)象然后求大小:

?
1
<s:property value="stus.{^#this.grade>=600}.{username}.size"/><br>

集合的偽屬性
OGNL能夠引用集合的一些特殊的屬性,這些屬性并不是JavaBeans模式,例如size(),length()等等. 當(dāng)表達(dá)式引用這些屬性時(shí),OGNL會(huì)調(diào)用相應(yīng)的方法,這就是偽屬性.

通過(guò)實(shí)例深入學(xué)習(xí)Java的Struts框架中的OGNL表達(dá)式使用

6.Lambda   :[…]
格式::[…]
使用Lambda表達(dá)式計(jì)算階乘:

?
1
<s:property value="#f = :[#this==1?1:#this*#f(#this-1)] , #f(4)"/><br>

7.OGNL中#的使用
#可以取出堆棧上下文中的存放的對(duì)象.

通過(guò)實(shí)例深入學(xué)習(xí)Java的Struts框架中的OGNL表達(dá)式使用

獲取Paraments對(duì)象的屬性:<s:property value="#parameters.username"/>

8.OGNL中%的使用
用%{}可以取出存在值堆棧中的Action對(duì)象,直接調(diào)用它的方法.

例如你的Action如果繼承了ActionSupport .那么在頁(yè)面標(biāo)簽中,用%{getText('key')}的方式可以拿出國(guó)際化信息.

9.OGNL中$的使用

“$”有兩個(gè)主要的用途

  1. 用于在國(guó)際化資源文件中,引用OGNL表達(dá)式
  2. 在Struts 2配置文件中,引用OGNL表達(dá)式

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 青青青久久久 | 女人张开腿让男人做爽爽 | 亚洲啊v| 亚洲福利二区 | 四虎成人免费观看在线网址 | 能播放的欧美同性videos | 亚洲国产一区二区三区青草影视 | 色中文网 | 精品推荐国产麻豆剧传媒 | 日本精品一区二区三区 | 亚洲国产黄色 | 邪恶肉肉全彩色无遮琉璃神社 | 欧美色在线 | 99九九精品视频 | 国产专区视频在线观看 | 麻生希在线观看 | 三星w999 | 国产成人在线综合 | 国产男女性特黄录像 | 国产成人精品视频频 | 无限在线看免费视频大全 | sss视频在线精品 | 激情艳妇之性事高h | 青青草成人在线观看 | 69热视频| 亚洲午夜视频 | 精品国产综合区久久久久久 | 日本人成大片在线 | 国产极品美女在线 | 日本成熟老妇xxxx | 天天久久综合 | 丝瓜视频成人在线观看 | 兽皇videos日本另类 | 国产va免费精品高清在线 | 日产欧产va1| 亚洲乱码尤物193yw在线播放 | 色老板视频在线观看 | 国产老太婆hd老头 | 99热久久这里只精品国产www | 天堂a免费视频在线观看 | 羞羞视频免费观 |