EL表达式语言(Servlet+jsp)
来源:互联网 发布:云计算大会ppt 编辑:程序博客网 时间:2024/05/16 05:41
1:Servlet
package cn.mldn.lxh.vo;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("serial")
public class ELListServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List<Dept> all=new ArrayList<Dept>();
Dept dept=null;
dept=new Dept();
dept.setDeptno(101);
dept.setName("开发工程师");
dept.setLoc("北京市");
all.add(dept);
dept=new Dept();
dept.setDeptno(102);
dept.setName("前端工程师");
dept.setLoc("北京市");
all.add(dept);
dept.setDeptno(103);
dept.setName("运维工程师");
dept.setLoc("北京市");
all.add(dept);
request.setAttribute("alldept", all);
request.getRequestDispatcher("el/list_dept.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
}
2:jsp(El表达式应用)
<%@ page contentType="text/html" language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML >
<html>
<head>
<title></title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
List all=(List)request.getAttribute("alldept");
if(all!=null)
{
%>
<div align="center">
<table border="1" width="50%">
<tr>
<td>部门编号</td>
<td>部门名称</td>
<td>部门位置</td>
</tr>
<%
Iterator iter=all.iterator();
while(iter.hasNext())
{
request.setAttribute("dept", iter.next());
%>
<tr>
<td>${dept.deptno}</td>
<td>${dept.name}</td>
<td>${dept.loc}</td>
</tr>
<%
}
%>
</table>
</div>
<%
}
%>
</body>
</html>
- EL表达式语言(Servlet+jsp)
- [Servlet&JSP] 表达式语言EL
- Servlet表达式语言(EL)
- 表达式语言(EL)---JSP
- JSP表达式语言(EL)
- JSP- EL表达式语言
- jsp---->EL表达式语言
- [JSP]EL表达式语言
- EL(JSP中的表达式语言)
- JSP表达式语言----EL语言
- Jsp的表达式语言(el)
- 初始JSP表达式语言-EL
- 09. JSP EL表达式语言
- 品茶看<Servlet&JSP>-EL表达式
- 表达式语言(EL)
- EL(表达式语言)
- EL(表达式语言)
- EL(表达式语言)
- 维护个人品牌,放大自我价值
- Bootstrap——页面基本样式
- 【5】python读取excel表格(from openpyxl import load_workbook)
- 通过外网ip访问tomcat
- 全选、反选
- EL表达式语言(Servlet+jsp)
- 数据结构——线性表—— 2016_10_13
- [BX] 和 loop指令
- 卷积神经网络
- 2.Android进阶:获取设备可用空间
- CSS设置子元素设置margin-top作用于父元素
- Tyvj P1077 CODE[VS] 2190 有理逼近
- 【基础4】WebDriver的部署
- Java之正则表达式入门理解