Values and labels for struts

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.