Pessoal,
com jsf 1.2 eu tenho de criar páginas .jsp ou posso criar xhtml?
criei a página index.xhtml como abaixo
<?xml version="1.0" encoding="ISO-8859-1" ?>
Ordem de Compra
</f:view>
mapiei ela como *.jsf na criação do projeto web, e quando tento acessar http://localhost:8080/Piloto/index.jsf
aparece uma página de erro do MyFaces falando:
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
já coloquei os jars dentro da pasta lib e quando criei o projeto já setei eles também…
alguém sabe o que pode ser? :roll:
Jovem,
Coloca seu XML pra eu dar uma olhada.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Piloto</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description>
This parameter tells MyFaces if javascript code should be allowed in
the rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default is 'true'</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
If true, rendered HTML code will be formatted, so that it is 'human-readable'
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default is 'true'</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default is 'false'
</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>faces</servlet-name>
<servlet-class>org.apache.myfaces.webapp.MyFacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>faces</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>faces</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
</web-app>
os jars são:
/Piloto/WebContent/WEB-INF/lib/commons-beanutils-1.8.3.jar
/Piloto/WebContent/WEB-INF/lib/commons-codec-1.3.jar
/Piloto/WebContent/WEB-INF/lib/commons-collections-3.2.jar
/Piloto/WebContent/WEB-INF/lib/commons-digester-1.8.jar
/Piloto/WebContent/WEB-INF/lib/commons-discovery-0.4.jar
/Piloto/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar
/Piloto/WebContent/WEB-INF/lib/myfaces-api-1.2.10.jar
/Piloto/WebContent/WEB-INF/lib/myfaces-impl-1.2.10.jar
:?: :?: :?:
o arquivo faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
</faces-config>
estão faltando as bibliotecas do JSTL
quando eu coloco os jars do jstl a página xhtml para de funcionar e o tomcat fica procurando index.jsp acusando que não existe
sendo que no meu projeto eu tenho index.xhtml e mapeio/acesso ela por index.jsf
alguma dica?
a jstl é essa mesma do link que vc indicou.
jstl-impl-1.2.jar
jstl-api-1.2.jar
e add elas na build path, naturalmente, mas mesmo assim nada!
vejam só o que retorna:
HTTP Status 404 - /Incode/index.jsp
type Status report
message /Incode/index.jsp
description The requested resource (/Incode/index.jsp) is not available.
parece que ta procurando jsp, mas quando criei mapiei por jsf e n existe pagina .jsp :@, isso só ocorre quando add os jars do jstl
pessoal resolvi alterando o web.xml, é necessário configurar o arquivo default como .xhtml
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
e no faces-config.xml é preciso colocar:
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
obrigado a todos!