我想在JSP页面中显示一个数据表。我的问题是我有一个表单,我有一个动作将我发送到我希望显示我的表的JSP页面。我以为我会使用另一个动作连接到数据库并获取我的所有信息,但我&#39 ;我不确定这是否有意义,我应该使用相同的动作吗?
以下是我的代码:
获取数据的行动:
import RegisterDao.*;
public class ProductAction {
private String name,price,godown,product_type, description ;
private int product_id;
public int getProduct_id() {
return product_id;
}
public void setProduct_id(int product_id) {
this.product_id = product_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGodown() {
return godown;
}
public void setGodown(String godown) {
this.godown = godown;
}
public String getProduct_type() {
return product_type;
}
public void setProduct_type(String product_type) {
this.product_type = product_type;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
JSP页面:
<%@ taglib uri="/struts-tags" prefix="s" %>
<table id="example" class="table table-bordered table-striped">
<thead>
<tr>
<th>Product Id</th>
<th>Godown</th>
<th>Name</th>
<th>Product Type</th>
<th>MRP</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<s:iterator value="list">
<tr>
<td><s:property value="product_id"/></td>
<td><s:property value="name"/></td>
<td><s:property value="price"/></td>
<td><s:property value="godown"/></td>
<td><s:property value="product_type"></s:property></td>
<td><s:property value="description"></s:property></td>
</tr>
</s:iterator>
</tbody>
</table>
struts.xml中:
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default,json-default">
<action name="product" class="Action.ProductAction">
<result type="json">
<param name="excludeNullProperties">true</param>
<param name="noCache">true</param>
</result>
</action>
</package>