“空转换器”的转换错误设置值-为什么我需要JSF中的转换器?
Warehouse
<h:selectOneMenu value="#{bean.selectedWarehouse}"> <f:selectItem itemLabel="Choose one .." itemValue="#{null}" /> <f:selectItems value="#{bean.availableWarehouses}" /></h:selectOneMenu>
@Named@ViewScopedpublic class Bean { private Warehouse selectedWarehouse; private List<SelectItem> availableWarehouses; // ... @PostConstruct public void init() { // ... availableWarehouses = new ArrayList<>(); for (Warehouse warehouse : warehouseService.listAll()) { availableWarehouses.add(new SelectItem(warehouse, warehouse.getName())); } } // ...}
Warehouse
SelectItem
.
转换错误设置值‘com.example.Warehouse@caebabe’空转换器‘。
Warehouse
SelectItem
SelectItem
Converter
Converter
<h:selectOneMenu>
Converter
getAsString()
SelectItem
getAsObject()
SelectItem
getAsObject()
相关分类