此数据提交author.setFindwithid()
:如何在此场景中重定向?
<h:form>
<h:outputLabel value="Id of to Be Edited record"></h:outputLabel>
<h:inputText value="#{author.id}"></h:inputText>
<h:commandButton value="submit" action="#{author.setFindwithid()}"/>
</h:form>
这里是author.setFindwithid()
public String setFindwithid() throws SQLException{
String query = "SELECT * FROM authors WHERE id=?";
PreparedStatement ps = con.prepareStatement(query);
ps.setInt(1, this.getId());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
Author tmp = new Author();
tmp.setId(rs.getInt("id"));
tmp.setName(rs.getString("name123"));
list.add(tmp);
}
return "UpdateAuthor.xhtml";
}
定义页面可以看到我有一个list
,我也重定向到UpdateAuthor.xhtml
。我想在UpdateAuthor.xhtml
范围内提供此list
,以便可以在视图中显示list
的值。我怎样才能做到这一点?
问题已经通过使用[此](http://stackoverflow.com/a/5406033/4913383)配有一个不同的问题 – user4913383
这个问题涉及解决。您可以只加载与目标页面关联的bean中的列表。 – BalusC