ricardo13 16 de nov. de 2010
Para facilitar vou escrever meu web.xml
<web-app>
<context-param>
<param-name> primefaces.skin</param-name>
<param-value> none</param-value>
</context-param>
<context-param>
<param-name> facelets.DEVELOPMENT</param-name>
<param-value> true</param-value>
</context-param>
<context-param>
<param-name> javax.faces.DEFAULT_SUFFIX</param-name>
<param-value> .xhtml</param-value>
</context-param>
<context-param>
<param-name> javax.faces.STATE_SAVING_METHOD</param-name>
<param-value> server</param-value>
</context-param>
<filter>
<filter-name> PrimeFaces FileUpload Filter</filter-name>
<filter-class> org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<init-param>
<param-name> thresholdSize</param-name>
<param-value> 51200</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name> PrimeFaces FileUpload Filter</filter-name>
<servlet-name> Faces Servlet</servlet-name>
</filter-mapping>
<listener>
<listener-class> com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class> org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name> Resource Servlet</servlet-name>
<servlet-class> org.primefaces.resource.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> Resource Servlet</servlet-name>
<url-pattern> /primefaces_resource/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name> Faces Servlet</servlet-name>
<servlet-class> javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name> Faces Servlet</servlet-name>
<url-pattern> *.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file> index1.xhtml</welcome-file>
</welcome-file-list>
</web-app>
… as libs …
servlet-api-2.5jsp-api-2.0
primefaces-1.1
jsf-api-1.2_02
jsf-impl-1.2-b19
jsf-facelets-1.11.1
commons-io-1.4
commons-fileupload-1.2.1
e a página index.xhtml
html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:p="http://primefaces.prime.com.tr/ui">
<head>
<title> Insert title here</title>
</head>
<body>
<f:view>
<h:form id= "form" prependId= "false" enctype= "multipart/form-data" >
<p:fileUpload auto= "false" label= "Selecionar..." allowTypes= "*.gif,*.png,*.jpg" multiple= "false"
description= "Imagem" fileUploadListener= "#{usuarioMB.upload}" update= "idimagem" />
<p:graphicImage id= "idimagem" value= "#{usuarioMB.foto}" />
<h:commandLink value= "Editar" action= "#{usuarioMB.atualizarUsuario}" />
<h:messages showDetail= "true" showSummary= "true" />
</h:form>
</f:view>
</body>
</html>
Ricardo