你好我正在学习primefaces并且我一直在尝试创建一个<p:fileUpload
标签,但是eclipse只是告诉我标签是未知的,当我在服务器上运行时会抛出错误,我已经导入了{ {1}}并通过commons-io , fileupload and primefaces jars
选项将库添加到webinf/lib
,但仍然没有,deployment assembly
也已配置,所以我做错了什么?
(编辑)页码:
web.xml
WEB.XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:rich="http://richfaces.org/rich"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<link rel="stylesheet" href="../css/nuevaEtapa.css" />
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'/>
</h:head>
<body>
<h1>Nueva Etapa</h1>
<a class="links" href="Administrador.xhtml">Administrador</a>
<div id="response"></div>
<h:form class="form" enctype="multipart/form-data">
<div class="input-wrapper" >
<h:inputText value="#{etapaBean.origen}" class="inputs" />
<h:inputText value="#{etapaBean.destino}" class="inputs" />
<h:inputText value="#{etapaBean.fecha}" class="inputs" />
<h:inputText value="#{etapaBean.hora}" class="inputs" />
<h:inputText value="#{etapaBean.categoria}" class="inputs" />
<h:inputText value="#{etapaBean.tipo}" class="inputs" />
<h:inputText value="#{etapaBean.nomPuerto}" class="inputs" />
<h:inputText value="#{etapaBean.alturaPto}" class="inputs" />
<h:inputText value="#{etapaBean.nomMapa}" class="inputs" />
<p:fileUpload fileUploadListener="#{fileUploadController.upload}" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" description="Select Images" ></p:fileUpload>
<img src="" class="imagen" width="200px" />
</div>
<h:commandButton class="btn" action="#{etapaBean.guardarEtapa()}" value="Guardar Etapa" id="cmdbtn" />
</h:form>
</body>
</html>
答案 0 :(得分:4)
你需要在页面中设置primefaces命名空间,就像这样
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
答案 1 :(得分:0)
将fileUploader放在一个单独的表格中,其中包含enctype =&#34; multipart / form-data&#34;。其他代码的其他形式没有属性enctype =&#34; multipart / form-data&#34;。并使用&lt; h:body&gt;。