【web后端(十八)】jsp、servlet_内置标签——UseBean
2023-09-11 14:20:37 时间
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<meta charset="UTF-8"/>
<%--放到ServletContext里头的东西,任何servelt都可以取的出来。--%>
<%--jsp也是servlet的一种,也在容器中。所以jsp也可以访问到自己的运行环境的引用。--%>
<%--只不过内置对象都是ServletContext,在jsp里面叫application。--%>
<%
ArrayList<ArrayList<String>> table = (ArrayList<ArrayList<String>>) application.getAttribute("table");
%>
</head>
<body>
<table border="0" cellspacing="0">
<th>empno</th>
<th>ename</th>
<th>job</th>
<th>mgr</th>
<th>hiredate</th>
<th>sal</th>
<th>comm</th>
<th>deptno</th>
<%
for (int i = 0; i < table.size(); i++) {
%>
<tr>
<%
ArrayList<String> row = table.get(i);
for (int j = 0; j < row.size(); j++) {
%>
<td><%=row.get(j)%>
</td>
<%
}
%>
</tr>
<%
}
%>
</table>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%--jsp的注释在客户端是看不到的--%>
<%--useBean标签的作用:实例化Bean--%>
<%--Bean其实就是java的组件,就是java类。但是,它遵循衣服那个的规范。--%>
<jsp:useBean id="stu" class="edu.xalead.Student" scope="session"/>
<%--给属性赋值--%>
<jsp:setProperty name="stu" property="id" value="10000"/>
<jsp:setProperty name="stu" property="name" value="zhangsan"/>
<jsp:setProperty name="stu" property="sex" value="M"/>
<%--取bean的属性--%>
<jsp:getProperty name="stu" property="id"/>:
<jsp:getProperty name="stu" property="name"/>:
<jsp:getProperty name="stu" property="sex"/>
</body>
</html>
相关文章
- web服务器、Web中间件和Web容器的区别
- web安全day42:使用BurpSuite理解Web工作机制
- org.apache.jasper.JasperException: Unable to compile class for JSP
- Jsp中无法使用EL表达式的解决方法错误Can not find the tag library descriptor for http://java.sun.com/jsp/jstl/core
- JSP九大内置对象及基本使用
- JSP文件管理后门工具jsp-file-browser
- 基于JSP+MySQL实现(Web)在线食品交易平台【100010259】
- 基于Java(JSP)实现(Web)教务管理信息系统【100010166】
- 基于Jsp+Bean+Servlet 实现(Web)简单的网上购书系统【100010129】
- 基于 Jsp+MySQL 实现(Web)个人动态分享心灵小阁网站【100010128】
- Go Web:RESTful web service示例
- CentOS7 nginx+tomcat实现代理访问java web项目让项目支持jsp和php
- SpringMVC访问WEB-INF下的jsp的方法
- 【IDEA】IDEA新建maven的web项目有pom.xml无Index.jsp
- 用最简单的话语教你使用JSP
- 【web后端(二十一)】jsp、servlet_EL表达式——scope范围中获取数据
- 【web后端(十四)】jsp、servlet_监听器
- 【web后端(十)】jsp、servlet_会话管理_servletContext
- 【web后端(七)】jsp、servlet_会话管理_隐藏域
- 【web后端(六)】jsp、servlet_会话管理_url重写
- 【web后端(二)】jsp、servlet_doPost_处理表单
- 【web后端(一)】jsp、servlet_查询字符串
- jsp中URL传递中文參数的处理
- Web 基础 之 Eclipse 中如何把新建的 jsp 文件默认的编码格式(ISO-8859-1)修改为 UTF-8,避免中文乱码
- Web测试中,各类web控件测试点总结
- @Java web程序员,在保留现场,服务不重启的情况下,执行我们的调试代码(JSP 方式)
- JSP(全称:Java Server Pages):Java 服务端页面