此數據提交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