JSTL和EL的区别

ELExpression Language(表达式语言)

EL的语法:${  EL exprission }

${  bean.name } 或  ${  bean['name'] }

说白了,EL是用来显示数据的,功能跟<%=表达式%> 一样,EL是不需要引入什么东西的

JSTLJavaServerPages Standard Tag LibraryJSP标准标签库

JSTL标准标签库包括核心标签库和SQL标签库,核心标签库常用的是ifforEach

说白了JSTL常实现网页逻辑判断和迭代显示的,需要引入

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

只要JSTLEL结合,就基本可以让页面再无<% %> jsp代码了。

给你一段我今天考试的代码:

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP 'index.jsp' starting page</title>

 <meta http-equiv="pragma" content="no-cache">

 <meta http-equiv="cache-control" content="no-cache">

 <meta http-equiv="expires" content="0">    

 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

 <meta http-equiv="description" content="This is my page">

 <!--

 <link rel="stylesheet" type="text/css" href="styles.css">

 -->

  </head>

  

  <body>

  <form action="work.do?method=search" method="post">

      <table border="1" align="center" width="50%">

    班级:<select name="student.s_class">

            <option value="0">全部</option>

     <c:forEach var="T_class" items="${requestScope.tClassList}">

      <option value="${T_class.c_no}">

       ${T_class.c_name}

      </option>

     </c:forEach>

    </select>

    科目:<select name="student.s_schedule">

        <option value="0">全部</option>

     <c:forEach var="T_schedule" items="${requestScope.tSchedultList}">

      <option value="${T_schedule.s_no}">

       ${T_schedule.s_name}

      </option>

     </c:forEach>

    </select>

    状态<select name="student.s_status">

        <option value="0">全部</option>

        <option value="1">已处理</option>

        <option value="2">未处理</option>

    </select>

    <input type="submit" value="提交">

   </table>

  </form>

  

  <c:if test="${requestScope.searchResult==0}">

  <h5 align=center>无此数据</h5>

  </c:if>

  

  <c:if test="${requestScope.searchResult==1}">

      <h3 align=center>查询结果如下</h3>

      <table border="1" align="center" width="50%">

      <tr>

      <th>姓名</th>

      <th>班级</th>

      <th>科目</th>

      <th>成绩/处理</th>

      </tr>

         <c:forEach var="MainBean" items="${requestScope.mainList}">

         <tr>

         <td>${MainBean.s_name}</td>

         <td>${MainBean.c_name}</td>

         <td>${MainBean.ts_name}</td>

         <td>

           <c:if test="${MainBean.s_status==1}">${MainBean.s_score}</c:if>

           <c:if test="${MainBean.s_status==2}"><a href="work.do?method=toPiyue&stuId=${MainBean.id}">批阅</a></c:if>

         </td>

         </tr>

         </c:forEach>

      </table></c:if>

  </body>

</html>

可能说得不是很清楚,这个多查查资料,多练练手就会了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值