当前位置:网站首页>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
边栏推荐
- Cross end solution to improve development efficiency rapidly
- Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
- Codeforces 12D Ball 树形阵列模拟3排序元素
- The primary key is set after the table is created, but auto increment is not set
- selenium 获取dom内验证码图片
- Some common processing problems of structural equation model Amos software
- sql常用语法记录
- Selenium gets the verification code image in DOM
- Experienced inductance manufacturers tell you what makes the inductance noisy. Inductance noise is a common inductance fault. If the used inductance makes noise, you don't have to worry. You just need
- Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
猜你喜欢
第05章_存储引擎
怎么利用Tensorflow2进行猫狗分类识别
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
Feng Tang's "spring breeze is not as good as you" digital collection, logged into xirang on July 8!
Reading and writing operations of easyexcel
R language [data management]
Teach yourself to train pytorch model to Caffe (2)
DBeaver同时执行多条insert into报错处理
使用Aspect制作全局异常处理类
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
随机推荐
Golang(1)|从环境准备到快速上手
Poj3414广泛搜索
PIP install beatifulsoup4 installation failed
Selenium finds the contents of B or P Tags
华为联机对战如何提升玩家匹配成功几率
Drawing HSV color wheel with MATLAB
Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
Get JS of the previous day (timestamp conversion)
面试官:并发编程实战会吗?(线程控制操作详解)
MySQL InnoDB Architecture Principle
秋招将临 如何准备算法面试、回答算法面试题
oracle 控制文件的多路复用
让开发效率提升的跨端方案
Making global exception handling classes with aspect
NET中小型企业项目开发框架系列(一个)
int GetMonth( ) const throw( ); What does throw () mean?
"Grain mall" -- Summary and induction
Teach yourself to train pytorch model to Caffe (I)
Zhang Lijun: penetrating uncertainty depends on four "invariants"
What should I do to prepare for the interview algorithm position during school recruitment?