gpt4 book ai didi

javax.el.PropertyNotFoundException : Property 'jobId' not found

转载 作者:行者123 更新时间:2023-12-01 18:11:24 24 4
gpt4 key购买 nike

我在尝试启动 Web 服务时收到此错误消息:org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: 在 com.bridge.service.Service 类型上找不到属性“jobId”

奇怪的是,jobId 在服务和我的数据库中都定义了,它将从中提取数据。

这是应该访问数据的函数。

public List<Service> getAllData() {

List<Service> data = new ArrayList<Service>();

try {
Class.forName(jdbc_driver);
// Connect to DB
Connection conn = DriverManager.getConnection(db_url, USER, PASS);

Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM email_data");
while (rs.next()) {
Service serv = new Service();
//UUID id = null;
serv.setId(rs.getString("jobId")); // error here
serv.setName(rs.getString("jobName"));
serv.setStatus(rs.getString("jobStatus"));
serv.setStart(rs.getTimestamp("start"));
serv.setFinish(rs.getTimestamp("finish"));
data.add(serv);
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
System.err.println("listing data, ya fucked up boi");
System.err.println(e.getMessage());
}

return data;
}

此外,在我的 JSP 文件中,它应该抓取数据,它被列为名为 jobId 的变量,如下所示。

<body>
<table border=1>
<thead>
<tr>
<th>Job ID</th>
<th>Job Name</th>
<th>Job Status</th>
<th>Start Time</th>
<th>Finish Time</th>
<th colspan=2>Action</th>
</tr>
</thead>
<tbody>
<c:forEach items="${jobs}" var="job">
<tr>
<td><c:out value="${job.jobId}"/></td>
<td><c:out value="${job.jobName}"/></td>
<td><c:out value="${job.jobStatus}"/></td>
<td><c:out value="${job.start}"/></td>
<td><c:out value="${job.finish}"/></td>
<td><a href="ServiceController?action=edit&jobId=<c:out value="${job.jobId}"/>">Update</a></td>
<td><a href="ServiceController?action=delete&jobId=<c:out value="${job.jobId}"/>">Delete</a></td>
</tr>
</c:forEach>
</tbody>
</table>
<p><a href="ServiceController?action=insert">Add Job</a></p>

有什么想法吗?我在这里不知所措。

编辑:这是Service.java:

public class Service {

private String jobId;
private String jobName;
private String jobStatus;
private Timestamp jobStart;
private Timestamp jobFinish;

public Service() {
// empty constructor
}

public Service(String id, String n, String s) {
jobId = id;
jobName = n;
jobStatus = s;
}

public String getId() {
return this.jobId;
}

public String getName() {
return this.jobName;
}

public String getStatus() {
return this.jobStatus;
}

public void setId(String id) {
this.jobId = id;
}

public void setName(String name) {
this.jobName = name;
}

public void setStatus(String status) {
this.jobStatus = status;
}

public void setStart(Timestamp time) {
this.jobStart = time;
}

public void setFinish(Timestamp time) {
this.jobFinish = time;
}

// SQL Info
static final String jdbc_driver = "com.mysql.jdbc.Driver";
static final String db_url = "jdbc:mysql://localhost:3306/email_data";

// SQL creds
static final String USER = "<redacted>";
static final String PASS = "<redacted>";

public void hygienePost(Service serv) throws Exception {

NewTask.toRabbit(serv.getId(), serv.getName(), serv.getStatus());
// System.out.println(serv.getId()+serv.getName()+serv.getStatus());

}

public List<Service> getAllData() {

List<Service> data = new ArrayList<Service>();

try {
Class.forName(jdbc_driver);
// Connect to DB
Connection conn = DriverManager.getConnection(db_url, USER, PASS);

Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM email_data");
while (rs.next()) {
Service serv = new Service();
// UUID id = null;
/*
serv.setId(rs.getString("jobId"));
serv.setName(rs.getString("jobName"));
serv.setStatus(rs.getString("jobStatus"));
serv.setStart(rs.getTimestamp("start"));
serv.setFinish(rs.getTimestamp("finish")); data.add(serv);
*/
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();

// The column count starts from 1
for (int i = 1; i < columnCount + 1; i++) {
String name = rsmd.getColumnName(i);
System.out.println(rs.getString(1));
}
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
System.err.println("listing data, ya fucked up boi");
System.err.println(e.getMessage());
}

return data;
}

}

最佳答案

它的 Jasper 异常(exception)。

serv.setId(rs.getString("jobid"));  // error here

您在服务类中提到了 setID 。那么属性就是id。

所以你需要这样做

<td><c:out value="${job.id}"/></td>

所以在 bean 类中不应该有不同的 propname 和 getter setter。应该是一样的。

所以请更改 getter 和 setter。

添加 getJobid 和 setJobid。

关于javax.el.PropertyNotFoundException : Property 'jobId' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32740580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com