First of all, we all know that there is a valuestack in struts2. The property inside the action is stored in it. At the same time, there is a stackcontext, which puts the map form of request/session/attr/application.
When the value is taken
The value in Valuestack
<s:property value= "User.Name" >
or use%{} in any of the <s:/> tags(remember that this is used inside the s tag to use%{})
The value in Stackcontext
<s:property value= ". Attr.user.name "> (there should be a user in request/session/attr/application at this time)
Using attr you don't know whether the user data is in request/session or anything else.
Besides, if in struts,
The official guidance given in the example is simple
<s:if test= "%{false}" > <div>will not being Executed</div></s:if><s:elseif test= "%{true} "> <div>will be executed</div></s:elseif><s:else> <div>will is Executed</div></s:else>
The screen will print out would be Executed
What does that mean?, which shows that%{} gets the value, not necessarily in valuestack.
Now that we've talked about Strtus's if, we might as well look at the IF in Jstl.
Besides Jstl if we look at the El operator first
The If of Jstl is as follows:
And we'll see what I'm having today with If.
List is the object inside the Valuestack.
The function I want to complete is if List.getindex (2). The content of GetContent () is the network priority
Let the dropdown box check the network priority by default
<s:if test= "%{list.{ content}[2]== Network Priority} "> <option value=" network Priority "Selected=" selected "> Network priority </option> </s:if> <s:else> <option value= "network priority" > Network priority </option> </s:else>
The code above must not be executed. Why?
Please refer to struts2 if label example
In other words, my code should look like this.
<s:if test= "%{list.{ Content}[2]==\ "Internet priority \"} "> <option value=" Internet priority "selected=" selected "> Internet priority </option> </s:if > <s:else> <option value= "Internet priority" > Internet priority </option> </s:else>
Resources
Proficient in Javaweb integrated development
http://blog.csdn.net/liehuoliaoyuan/article/details/7426085
http://blog.csdn.net/dlf123321/article/details/28645369
http://hw1287789687.iteye.com/blog/1949722
Values and labels for struts