在 JSP 中,使用 TR 循环可以方便地遍历数据并将结果以表格形式展示。以下是一个简单的实例教程,展示如何使用 JSP 中的 TR 循环。

实例教程

1. 准备数据

我们需要准备一些数据。这里我们使用一个简单的 Java 对象数组来模拟数据。

JSP中使用TR循环实例教程  第1张

```java

public class Product {

private String name;

private double price;

public Product(String name, double price) {

this.name = name;

this.price = price;

}

public String getName() {

return name;

}

public double getPrice() {

return price;

}

}

// 创建产品列表

Product[] products = {

new Product("