El expression in JSP gets data _java

Source: Internet
Author: User

JSP Tags:

<jsp:include>
<jsp:forward> Implementation Request Forwarding
<jsp:param> to add parameters to the above

El expression:

1. Get Variable data

<%
String name= "Taoshan";
Pagecontext.setattribute ("name", name);
%>

Hello, ${name}

2. Get Array data

<%
string[] names={"Taoshan", "John"};
Pagecontext.setattribute ("names", names);
%>

Hello, ${names[0]}

3. Get Collection data

<%
list<string> names=new arraylist<string> ();
Names.add ("Taoshan");
Names.add ("John");
Pagecontext.setattribute ("names", names);
%>

Hello, ${names[1]}

<%
map<string,string> names=new hashmap<string,string> ();
Names.put ("name", "Taoshan");
Pagecontext.setattribute ("names", names);
%>

Hello, ${names[' name ']} ${names.name}

4. Get JavaBean Data

Note to guide the package, the expression automatically adjust Get method

<% person
person=new person ();
Person.setname ("Taoshihan");
Pagecontext.setattribute ("person", person);
%>

Hello, ${person.name}

Path: ${pagecontext.request.contextpath} = = <%=request.getcontextpath ()%>

Related Article

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.