Value Stack: equivalent to a stack. Each action class object instance will have a valuestack object. When struts
2. Receive. after an action request, an object instance of the action class will be created, and the corresponding attributes of the action class will be placed on the top-level node of the valuestack object. All attribute values are default values, for example, if the attribute value of the string type is
Null, int type attribute value is 0, and so on. Then struts 2 will call the interceptor in the interceptor chain. After all the interceptors are called, the action method of the action class will be called.
The attribute value in the top-level node of the valuestack object is assigned to the corresponding attribute in the action class. Similarly, if the attribute in the action changes when the returned result is returned, the corresponding attribute in the value Stack also changes.
Ognl:
Struts2 sets actioncontext as the ognl context and places the value stack as the root object of ognl into actioncontext. That is, the content in actioncontext can be accessed through ognl, use ognl directly:
Ognl does not need to add # To get the content in the value stack. It must add # To get content outside the value stack #,
Reference: struts2 ognl detailed http://www.cnblogs.com/xly1208/archive/2011/11/19/2255500.html
1. the attribute or getter method modified by public in the object can be called, similar to the El expression.
For example, obj. Prop first searches for the getprop () method in the find OBJ method, but cannot find the prop attribute. If not, an empty string is returned.
2. Call the methods in the object to directly use obj. methdo (ARGs) such as student. getname (); sudent. setname ("small red"); Note: The Void returned by the method is not displayed.
3. Static attributes and methods in the call class
Use @ package. classname @ classprop or @ package. classname @ staticmethod (ARGs)
Example: @ java. Lang. Math @ pi @ util. dateutil @ formatdate (today, 'yyyy-mm-dd ')
Remember that there is no "." Operator between the full path of the class and the method name plus @ class and method. If it is written as @ package. classname. @ staticprop, it is wrong.
4. Set Operations:
Map. Key and map [Key] Get the value corresponding to a key in the map, list [Index] Get the elements whose end is index in the set. The set cannot obtain the nth element through this method.
{E1, E2, E3 ...} Generate list object # {key1: value1, key2: value2 ,...} Generate a map object
The in expression is used to determine whether an element is in a specified set object.
Not in determines whether an element is not in the specified set object.
? : Obtain all logical elements
^: Obtain the first logical element.
$: Get the last logical element.
See http://book.51cto.com/art/200806/75772.htm
Some common methods in Java Collection APIs do not comply with the getter and setter naming rules of JavaBean. Therefore, they cannot be accessed like accessing the JavaBean attribute. ognl provides some pseudo attributes, this allows you to call these methods like access attributes:
List, set, MAP: Size, isempty
List, set: iterator
Map: Keys, values
Iterator: Next, hasnext
Enumeration: Next, hasnext, nextelement, hasmoreelements
See: http://hi.baidu.com/sisovrcetggmqwr/item/9c96c9c08563731a515058db
5. Support constructor new pojo. Student (ARGs)
6. You can directly assign values using equal signs.
7. ognl expressions are automatically converted During computation. Note that
Difference between % {'hello'} and % {Hello}
Struts2 label:
Struts2 is equivalent to an upgraded version of webwork. Therefore, the original webwork tag can be directly used in struts2.
Download webwork 2.0 tags to view the API
You can also refer
Control label:
* If * elseif * else * append * Generator * iterator * merge * sort * subset
If tag attribute: The test attribute returns true or false to control whether HTML in the IF tag is displayed. ID indicates that the value of the test expression is put in the context (not in the value stack) for access elsewhere.
If can be used independently, it can be used together with elseif and Else.
Append is used to convert multiple iterators into one iterator. When this iterator is used, each iterator in the iterator is called in sequence. When an iterator ends, the next iterator starts.
The MERGE table is also used to convert multiple iterators into one iterator. When this iterator is used, the first element of each iterator is obtained in sequence, then, extract the second element from each iterator in sequence ,... until each iterator ends.
Generator: separates strings and provides an iterator for convenient traversal. Val provides the string to be separated. Separator indicates the string to be separated, id indicates that the provided iterator is placed in the context for use elsewhere, and converter indicates the converter, which must be Org. apache. struts2.util. iteratorgenerator. converter implementation Class Object, used to process each split string, converted to the format or object we need
Sort sorts the content in the provided iterator, and then provides an iterator for external users.
Subset filters the iterator Based on the filters we provide, and then provides the iterator for the processed data.
The status in the iterator iteration isOrg. Apache. struts2.views. jsp. iteratorstatusObject
• Index: current iteration index, starts on 0 and increments in one on every iteration
• Count: iterations so far, starts on 1. Count is always index + 1
• First: true if Index = 0
• Even: true if (index + 1) % 2 = 0
• Last: true if current iteration is the last iteration
• Odd: true if (index + 1) % 2 = 1
The attributes of each control label are listed as follows: