jsp用基础的html显示
时间: 2024-02-26 15:59:12 浏览: 72
JSP页面可以使用基础的HTML标记来进行显示。例如,可以使用HTML的表格标记来显示数据,如下所示:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample JSP Page</title>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
</tr>
<tr>
<td>Jane</td>
<td>23</td>
</tr>
</table>
</body>
</html>
```
这个HTML代码可以在JSP页面中直接使用,也可以通过JSP标记来插入动态数据,例如:
```html
<%@ page import="java.util.ArrayList" %>
<%
ArrayList<String> names = new ArrayList<String>();
names.add("John");
names.add("Jane");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample JSP Page</title>
</head>
<body>
<table>
<tr>
<th>Name</th>
</tr>
<%
for (String name : names) {
%>
<tr>
<td><%= name %></td>
</tr>
<%
}
%>
</table>
</body>
</html>
```
这个JSP页面中使用了一个ArrayList来存储名字数据,并通过JSP标记来循环输出表格中的行。其中,`<%` 和 `%>` 标记用于插入Java代码,`<%= %>` 标记用于输出Java表达式的值。
阅读全文
相关推荐
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)