[JavaEE] EL expression to get data, javaeeel

Source: Internet
Author: User

[JavaEE] EL expression to get data, javaeeel

Jsp Tag:

<Jsp: include>

<Jsp: forward> implement request forwarding

<Jsp: param> Add the Parameter

 

EL expression:

 

1. Get variable data

<%

String name = "Tao shihan ";

PageContext. setAttribute ("name", name );

%>

Hello, $ {name}

 

2. Get array data

<%

String [] names = {"Tao shihan", "Zhang San "};

PageContext. setAttribute ("names", names );

%>

Hello, $ {names [0]}

 

3. Get collection data

<%

List <String> names = new ArrayList <String> ();

Names. add ("Tao shihan ");

Names. add ("James ");

PageContext. setAttribute ("names", names );

%>

Hello, $ {names [1]}

 

<%

Map <String, String> names = new HashMap <String, String> ();

Names. put ("name", "Tao shihan ");

PageContext. setAttribute ("names", names );

%>

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

 

4. Obtain the javabean data

Note that you need to export the package, and the expression automatically calls the get method.

<%

Person person = new Person ();

Person. setName ("taoshihan ");

PageContext. setAttribute ("person", person );

%>

Hello, $ {person. name}

Path: $ {pageContext. request. contextPath }=<%= request. getContextPath () %>

 

 

 

 

5. Execute operations

Obtain common development objects

Call the java method

 

 

JSTL:

 

Custom Tag:

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.