当前位置:网站首页>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
边栏推荐
- 总结出现2xx、3xx、4xx、5xx状态码的原因
- Two ways to realize video recording based on avfoundation
- Robot operation mechanism
- Chap2 steps into the palace of R language
- 华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
- Introduction of ArcGIS grid resampling method
- Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
- How to prepare for the algorithm interview and answer the algorithm interview questions
- QML reported an error expected token ";", expected a qualified name ID
- Kingbasees v8r3 cluster maintenance case -- online addition of standby database management node
猜你喜欢
uni-app 蓝牙通信
冯唐“春风十里不如你”数字藏品,7月8日登录希壤!
第05章_存储引擎
Making global exception handling classes with aspect
Teach yourself to train pytorch model to Caffe (III)
2022-07-03-cka- latest feedback from fans
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
Realize the function of verifying whether the user has completed login when browsing the page
What should I do to prepare for the interview algorithm position during school recruitment?
SQL knowledge leak detection
随机推荐
SQL knowledge leak detection
使用Aspect制作全局异常处理类
Selenium finds the contents of B or P Tags
GCC9.5离线安装
他们主动布局(autolayout)环境的图像编辑器
Simple interest mode - lazy type
Xlrd common operations
大约SQL现场“这包括”与“包括在”字符串的写法
selenium 查找b或p标签的内容
Yolov5 training custom data set (pycharm ultra detailed version)
Get JS of the previous day (timestamp conversion)
Alibaba cloud award winning experience: build a highly available system with polardb-x
怎么利用Tensorflow2进行猫狗分类识别
HDU 4391 Paint The Wall 段树(水
第05章_存储引擎
854. 相似度为 K 的字符串 BFS
Ethereum ETH的奖励机制
MMAP learning
Emotional analysis of wechat chat records on Valentine's day based on Text Mining
MySQL deep paging optimization with tens of millions of data, and online failure is rejected!