EL表达式jstl

jstl 是与 EL表达式 结合使用,代替之前的jsp脚本

 使用jstl标签库:  1.导入jar包    <%@page import="com.zr.entity.Goods"%>
                  2.引入核心标签库,需要配置指令       
              3.设置标签前缀c  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
             
  out 相当于     <%= 表达式   % >
  if 判断         test判断属性         条件成立显示if双标签中间的内容      不成立不显示
  contains(‘字符’) 包含    查询字符串中有没有包含此字符
  
  c:forEach  循环
  items属性 :  存放你要遍历的内容(内容需要结合EL表达式作用域key) 
  var :给循环的对象起别名 
  varStatus:  通过下标记录编号   index+1
              count  记录数量
              first  第一行是true  其他false
              last   最后一行是true 其他是false
              
request.setAttribute("name", "小兰");
  
  Goods g = new Goods();
  g.setGname("1,3");
  g.setGprice(29);
  g.setGsum(1);
  request.setAttribute("g", g);
   <c:out value="${name }"></c:out> 

<c:if test=" g . g s u m = = 10 &quot; &gt; 库 存 对 &lt; / c : i f &gt; &lt; c : i f t e s t = &quot; {g.gsum==10 }&quot;&gt;库存对&lt;/c:if&gt; &lt;c:if test=&quot; g.gsum==10"></c:if><c:iftest="{g.gsum!=10 }">库存错误</c:if>

<c:if test="${g.gname.contains(‘四’) }">名字中含有三</c:if>

<input type=“checkbox” name=“h” value=“1” <c:if test=" g . g n a m e . c o n t a i n s ( ′ 1 ′ ) &quot; &gt; c h e c k e d &lt; / c : i f &gt; / &gt; 打 游 戏 &lt; i n p u t t y p e = &quot; c h e c k b o x &quot; n a m e = &quot; h &quot; v a l u e = &quot; 2 &quot; &lt; c : i f t e s t = &quot; {g.gname.contains(&#x27;1&#x27;) }&quot;&gt;checked&lt;/c:if&gt; /&gt;打游戏 &lt;input type=&quot;checkbox&quot; name=&quot;h&quot; value=&quot;2&quot; &lt;c:if test=&quot; g.gname.contains(1)">checked</c:if>/><inputtype="checkbox"name="h"value="2"<c:iftest="{g.gname.contains(‘2’) }">checked</c:if> />打豆豆
<input type=“checkbox” name=“h” value=“3” <c:if test=" g . g n a m e . c o n t a i n s ( ′ 3 ′ ) &quot; &gt; c h e c k e d &lt; / c : i f &gt; / &gt; 睡 觉 &lt; i n p u t t y p e = &quot; c h e c k b o x &quot; n a m e = &quot; h &quot; v a l u e = &quot; 4 &quot; &lt; c : i f t e s t = &quot; {g.gname.contains(&#x27;3&#x27;) }&quot;&gt;checked&lt;/c:if&gt; /&gt;睡觉 &lt;input type=&quot;checkbox&quot; name=&quot;h&quot; value=&quot;4&quot; &lt;c:if test=&quot; g.gname.contains(3)">checked</c:if>/><inputtype="checkbox"name="h"value="4"<c:iftest="{g.gname.contains(‘4’) }">checked</c:if> />吃好吃的

<c:forEach items=" l i s t &quot; v a r = &quot; s &quot; v a r S t a t u s = &quot; i &quot; &gt; &lt; t r &lt; c : i f t e s t = &quot; {list }&quot; var=&quot;s&quot; varStatus=&quot;i&quot;&gt; &lt;tr &lt;c:if test=&quot; list"var="s"varStatus="i"><tr<c:iftest="{i.count%2!=0 }">bgcolor=‘red’</c:if>
<c:if test="KaTeX parse error: Expected '}', got 'EOF' at end of input: … <td>{i.first }
i . l a s t &lt; / t d &gt; &lt; t d &gt; {i.last }&lt;/td&gt; &lt;td&gt; i.last</td><td>{i.index+1 }

          <td>${s.id }</td>
          <td>${s.name }</td>
          <td>${s.type }</td>
      </tr>
   </c:forEach>

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值