当前位置:网站首页>Summary of El and JSTL precautions
Summary of El and JSTL precautions
2022-07-05 21:43:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack , I've prepared for you today Idea Registration code .
EL Use expressions (5 One problem ) JSTL Use a label (5 problem ) What is? EL. It can be used for ? EL full name Expression Language stay JSP Use page Lattice formula ${ expression } Examples ${requestScope.customer.id} function : 1. Only four domain objects were taken out to display the attribute data
(pageContext.request.session.application)
2. Take out the request parameter data and display
<% request.setAttribute(“person”,new Person(“xfzhanag”,18)); %> Map<String,Person> map=new HashMap<String,Person>(); map.put(“A”,new Person(“AA”,12)); map.put(“”B”,new Person(“BB”,13)); map.B.age
{requestScope.person.name}; {requestScope.person[‘name’]}; List The second data in it <%
<% List list=new ArrayList(); list.add(“a”); list.add(“b”); list.add(“c”); request.setAttribute(“List”,list);
%>
{requestScope.List[1]}; {requestScope.List[‘name’]};
My age :<requestScope.person.name><br/> // What's convenient ? Why is there a bracket ? /* A situation ? ${requestScope[‘my person’].name}; map.put(“my person”,new Person(“Xxx”,12));
*/ EL Operations that can be performed ? Arithmetic operation (+,-, * ,/ ,%) Relationship between operation (>,<,==,!=) Logical operations (&&,||) empty operation ( Infer whether a data is empty ) (null, An empty string , Empty set )
{empty name}<br>
Three item conditional operation {requestScope.person.age>18 ? ‘ adult ’ : ‘ A minor ’ }
fmt:formDate SQL Tag library sql http://sun.com/jsp/jstl/sql sql:query xml Tag library xml http://sun.com/jsp/jstl/fmt x:forBach Function tag library fn http://sun.com/jsp/jstl/function fn:split Why use JSTL? stay jsp Use in jsp Script +jsp Expressions can also do circular output , too troublesome EL Can't do traversal work JSTL Be able to do this and work with jsp and html The labels of can be combined very well JSTL High speed entry 1. Import JSTL dependent jar package : jstl.jar standard.jar
2. stay jsp Import... Into the file JSTL Of c Tag library <%@ taglib uri=”http://java.sun.com/jsp/jstl/core” perfix=”c”
%>
3 <% List<String> list=new ArrayList<String>(); list.add(“A”); list.add(“B”); list.add(“C”); request.setAttribute(“list”,list);
%> <c:forEach items=”
jstl How to do process control ? c:if( A conditional inference ) c:choose c:when
// demand 1: Suppose I'm younger than 18 Export minors ( In red ) <c:if test=”${person.age<18}”> <font color=”red”> minors </font> </c:if>
demand 2: Suppose you are older than 60, It outputs ’ Old man ‘ Suppose you are younger than 18, It outputs ” Small fart child ” Other . It outputs ” adults ” <br/> <c:choose> <c:when test=”${person.age>60}”> Old man
</c:when> <c:when test=”${person.age<18}”> Small fart child
</c:when> <c:otherwise> adults </c:otherwise> </c:choose> jstl How to traverse ? <% Map<String,Person> map=new
HashMap<String,Person>(); map.put(“1”,new Person(“AA”,23)); map.put(“2”,new Person(“BB”,23)); map.put(“3”,new Person(“CC”,23)); map.put(“4”,new Person(“DD”,23)); map.put(“5”,new Person(“EE”,23)); map.put(“6”,new Person(“FF”,23)); request.setAttribute(“personMap”,map); %> <h3> Display the data in a table </h3> <table border=”1″ style=”width:300px”> <tr> <td>ID</td> <td> full name </td> <td> Age </td> </tr> <c:forEach items=”{item.key}</td> <td>
Copyright notice : This article is an original blog article , Blog , Without consent , Shall not be reproduced .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117575.html Link to the original text :https://javaforall.cn
边栏推荐
- Golang(1)|从环境准备到快速上手
- Pointer parameter passing vs reference parameter passing vs value parameter passing
- Gcc9.5 offline installation
- int GetMonth( ) const throw( ); What does throw () mean?
- R language [data management]
- Zhang Lijun: penetrating uncertainty depends on four "invariants"
- Longest swing sequence [greedy practice]
- Environment configuration problem record
- MySQL deep paging optimization with tens of millions of data, and online failure is rejected!
- 阿里云有奖体验:用PolarDB-X搭建一个高可用系统
猜你喜欢
华为快游戏调用登录接口失败,返回错误码 -1
总结出现2xx、3xx、4xx、5xx状态码的原因
Emotional analysis of wechat chat records on Valentine's day based on Text Mining
Cross end solution to improve development efficiency rapidly
Evolution of zhenai microservice underlying framework from open source component encapsulation to self-development
MySQL InnoDB Architecture Principle
冯唐“春风十里不如你”数字藏品,7月8日登录希壤!
Making global exception handling classes with aspect
华为联机对战如何提升玩家匹配成功几率
KingbaseES V8R3集群维护案例之---在线添加备库管理节点
随机推荐
Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines
uni-app 蓝牙通信
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
MQ----activeMq
Reading and writing operations of easyexcel
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
Teach yourself to train pytorch model to Caffe (I)
Exercise 1 simple training of R language drawing
冯唐“春风十里不如你”数字藏品,7月8日登录希壤!
Teach yourself to train pytorch model to Caffe (III)
有些事情让感情无处安放
第05章_存储引擎
Alibaba cloud award winning experience: build a highly available system with polardb-x
【日常训练】729. 我的日程安排表 I
如何组织一场实战攻防演练
PostGIS installation geographic information extension
【日常训练--腾讯精选50】89. 格雷编码(看题解才会的)
2022-07-03-CKA-粉丝反馈最新情况
Analysis and test of ModbusRTU communication protocol
校招期间 准备面试算法岗位 该怎么做?