Struts 2 使用 s:iterator 仅显示 mysql table 上 JSP 的一行
Struts 2 only displaying one row from mysql table on JSP using s:iterator
我在使用 struts 2 时遇到了一个非常奇怪的问题,我正在使用 s:iterator 来提取问题列表,但是当我使用 s:property 标签时,只有将显示 ID,仅此而已。有4列,id,groupid,subgroupid和questiontxt但我似乎只能显示ID。我测试了列表,它包含所有列,它已从数据库中正确保存它们,但我唯一能够在屏幕上显示的是 ID。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href=<s:url value="resources/welcome.css" /> rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome</title>
</head>
enter code here
<body>
<table>
<s:iterator value="listQuestionsBasic" var="question">
<tr>
<td>
<s:property value="#question.id" />
</td>
</tr>
<tr>
<td>
<s:property value="#question.groupid" />
</td>
</tr>
<tr>
<td>
<s:property value="#question.subgroupid" />
</td>
</tr>
<tr>
<td>
<s:property value="#question.questiontxt" />
</td>
</tr>
</s:iterator>
</table>
</body>
</html>
所以我根据适当的 java 礼节重命名变量解决了这个问题,IE questiontxt 列为 String questionTxt,而不是 String questiontxt。
我要一杯啤酒。
我在使用 struts 2 时遇到了一个非常奇怪的问题,我正在使用 s:iterator 来提取问题列表,但是当我使用 s:property 标签时,只有将显示 ID,仅此而已。有4列,id,groupid,subgroupid和questiontxt但我似乎只能显示ID。我测试了列表,它包含所有列,它已从数据库中正确保存它们,但我唯一能够在屏幕上显示的是 ID。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href=<s:url value="resources/welcome.css" /> rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome</title>
</head>
enter code here
<body>
<table>
<s:iterator value="listQuestionsBasic" var="question">
<tr>
<td>
<s:property value="#question.id" />
</td>
</tr>
<tr>
<td>
<s:property value="#question.groupid" />
</td>
</tr>
<tr>
<td>
<s:property value="#question.subgroupid" />
</td>
</tr>
<tr>
<td>
<s:property value="#question.questiontxt" />
</td>
</tr>
</s:iterator>
</table>
</body>
</html>
所以我根据适当的 java 礼节重命名变量解决了这个问题,IE questiontxt 列为 String questionTxt,而不是 String questiontxt。
我要一杯啤酒。