【发布时间】:2009-11-28 18:22:29
【问题描述】:
我在 JSF 上有以下 UI 部分 - 这是带有输入字段并提交的简单搜索表单:
<h:form>
<h:commandButton action="#{operation.found}" value="#{msg.search}" />
<h:inputText name="searchParam"/>
</h:form>
相应地,在后端,我尝试获取输入字段的值:
public List<Store> getFound() {
String name = (String) FacesContext.getCurrentInstance()
.getExternalContext().getRequestParameterMap().get(
"searchParam");
SessionFactory sessionFactory = new Configuration().configure()
.buildSessionFactory();
HibernateTemplate hbt = new HibernateTemplate();
hbt.setSessionFactory(sessionFactory);
foundStores = hbt.find(BEAN_PATH + " WHERE name = ?",
new Object[] { name });
return foundStores;
}
并将空名称传递给后端。
.jsf 部分似乎有问题,但乍一看还可以...
【问题讨论】:
标签: forms jsf parameters request submit