[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: