我在托管bean中有一个Map
private Map<FaseProducao, Set<FichaTecnicaOperacao>> fichasTecnicasOperacaoResumo;对实体FichaTecnica的引用:
public class FichaTecnica{
//...
private Set<FichaTecnicaOperacao> operacoes;
}它需要作为beans.put ()上的参数传递,以便使用jett生成xls:
public void createRelatorioFichaTecnica(FichaTecnica fichaTecnica) throws IOException {
//ommited...
Map<String, Object> beans = new HashMap<String, Object>();
beans.put("operacaoResumo", fichasTecnicasOperacaoResumo);
try (ByteArrayOutputStream saida = new ByteArrayOutputStream();
InputStream template = this.getClass().getResourceAsStream("/templates/jett/fichaTecnica.xls");
Workbook workbook = transformer.transform(template, beans);) {
//ommited...
}
}当生成xls时,会发生异常:
WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-28) #{ProdutoManagedBean.createRelatorioFichaTecnica(row)}: net.sf.jett.exception.AttributeExpressionException: Expected a "java.util.Collection" for "items", got a "java.util.HashMap": "${operacaoResumo}".所以我不理解这个错误,因为Map是一个正确的集合?那么,为什么杰特在条目= "$ {operacaoResumo}“中不认识它呢?我根据站点上的链接创建了这个forEach:http://jett.sourceforge.net/tags/forEach.html
发布于 2019-07-11 19:38:25
就像@rgettman说的那样:
public void createRelatorioFichaTecnica(FichaTecnica fichaTecnica) throws IOException {
//ommited...
Map<String, Object> beans = new HashMap<String, Object>();
beans.put("operacaoResumo", fichasTechicasOperacaoResumo.keySet());
}谢谢大家!
https://stackoverflow.com/questions/46156593
复制相似问题