A: <s: if> judge the string: 1. Judge A single character: <s: if test = "# session. user. username = 'C' "> in this way, the username value is retrieved from the session and determined whether it is c. However, this is incorrect, it cannot be determined at all. It should be changed to the following: <s: if test = "# session. user. username = 'C '. toString () "> in this way, we can make a correct judgment. I don't know the reason. on the Internet, we can see that struts2 may judge the char type. 2. Judge the string: <s: if test = "# session. user. username = 'milo' "> in this case, it is written to judge whether username is milo or String. This does not need to be added with toString. 3. Value: <s: if test = "# session. user. username = 0"> in this case, the value is int. B: NULL: <s: if test = "# session. user. username = null "> In struts2, it seems that the null value can only be written in this way to judge whether it is not null. You can write it like this: <s: if test =" # session. user. username! = Null "> ps: If the property value is obtained from the action, '#' before the property value in test is not required. The property in action is interconnected with the property in jsp. Character --------------------------- string N must be enclosed by "" Double quotation marks. The test contains single quotation marks ''. If it is the opposite, the attribute cannot be correctly determined whether it is equal to the string. Correct: <s: if test = 'activitybean. searchForce = "N" '> error: <s: if test = "activityBean. searchForce = 'n' "> Because java is a strong type language, single quotation marks indicate the char type. Only one character can be assigned to the char type, while double quotation marks indicate the String type, so my activityBean. the searchForce attribute is of the String type, then, double quotation marks/********************************* must be used for N /********************************** **************************************** **************************************** **************************************** * ** for example, this statement is used to determine systemSettingModel In the struts stack. Whether. settingValue is equal to "A" written as <s: if test = "systemSettingModel. settingValue = 'A'">... </s: if> is incorrect. In this way, A is considered A character, while systemSettingModel. settingValue is a single character string. if it does not match, it should be written as <s: if test = 'systemsettingmodel. settingValue = "A" '>... </S: if> or <s: if test = "systemSettingModel. settingValue = \" A \ "">... </s: if> refer: http://struts.apache.org/2.1.8.1/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html In addition, systemSettingModel. the value of settingValue can be $ {systemSettingModel. settingValue} <s: property value = "systemSettingModel. settingValue "/> <s: property value =" # request. systemSettingModel. settingValue "/> # indicates that it is not in the struts stack, no # indicates retrieving/********************************* from the struts stack /******************************* **************************************** **************************************** **************************************** ** tags in Struts2 Stack S: When should the href in a use "#" and "% {}" be used and "% {#}" be used? "s: when should I use "#" for the list in the select statement? "% {}"? When should I use "% {#}"? "s: when should I use "#" for test in if? When should I use "% {}"? When should I use "% {#}"? When should I use "s: when should "#" be used for the value IN iterator, "% {}", "% {#}", and "" s "be used: when should "#" Be used for the list in the checkboxlist, "% {}", "% {#}", and "" Struts2 "have the concept of value stack and stack context?, you can see from <s: debug/>. in the S tag, # is used to retrieve the objects stored in the stack context. you can use % {} to retrieve the Action object in the value stack. Method to call it. for example, if your Action inherits ActionSupport. in the page tag, % {getText ('key')} can be used to obtain international information. % {#}. This is the syntax in JSP2.1's latest specification, it is written as % {#} in the domain object for Struts2 to solve the compatibility problem. For example, % {# session. user. userName} will get the userName attribute value of the user object % {}. It is emphasized that % {} is taken from the root point you set for the calculation expression. For example, % {10 + 20}, the result will be output for 30.% {"a" + "B"} results will be output "AB" # normally, the emphasis is given from the context as # parameters. name [0] is equivalent to request. getParameter ("name") for example # session. name is equivalent to session. getAttribute ("name") such as # request. name is equivalent to request. getAttr Ibute ("name") % {#} is still used to calculate the expression, but the operation element can be a variable. For example, if you first define a variable <s: set name = "age" value = "% {25}"/> % {# age} Will output 25, or you can omit "#", write as % {age}. If you add age to 10, you can write as follows: % {# age + 10} and output 30. "#" cannot be omitted "#". That is to say, when a variable is used for calculation, it cannot be omitted. ========================================================== ============================ #, %, $ #, and % in ognl and $ are frequently used in OGNL expressions, these three symbols are also a part that developers cannot easily grasp and understand. Here, I will briefly introduce their respective uses. 1. # There are generally three types of symbols. 1) access non-root object attributes. For example, the # session. msg expression in the example. Because the Struts 2 mid-value stack is regarded as the root object, the # prefix is required when accessing other non-root objects. In fact, the expression # is equivalent to ActionContext. getContext (); # session. msg is equivalent to ActionContext. getContext (). getSession (). getAttribute ("msg "). 2) used for filtering and projecting sets, such as persons .{? # This. age> 20 }. 3) used to construct a Map. For example, # {'foo1': 'bar1', 'foo2': 'bar2'} in the example ′}. 2.% The purpose of the symbol % is to calculate the value of the OGNL expression when the flag attribute is of the string type. The following code constructs a Map <s: set name = "foobar" value = "# {'foo1': 'bar1', 'foo2 ′: 'bar2'} "/> <p> The value of key" foo1 "is <s: property value = "# foobar ['foo1']"/> </p> <p> do not use %: <s: url value = "# foobar ['foo1']"/> </p> <p> usage %: <s: url value = "% {# foobar ['foo1']}"/> </p> 3. the $ symbol has two main purposes. REFERENCE The OGNL expression in the international resource file. For example, in the international resource file code: reg. agerange = International Resource Information: The age must be between $ {min} and $ {max. REFERENCE The OGNL expression in the configuration file of the Struts 2 framework, as shown in the following code snippet: <validators> <field name = "intb"> <field-validator type = "int"> <param name = "min"> 10 </param> <param name = "max "> 100 </param> <message> BAction-test Verification: the number must be between $ {min} and $ {max! </Message> </field-validator> </field> </validators>