EdersonPJ 23 de dez. de 2006
isso acontece pq o netbeans mapeia a instancia do FacesServlet para /faces/* vc pode ver isso no web.xml
vc pode fazer um index.jsp que redireciona para /faces/seuJsp.jsp
algo como <html>
<head>
</head>
<body>
<jsp:forward page="faces/index2.jsp" />
</body>
</html>
vc pode ver um exemplo disso no The Java EE 5 Tutorial: http://java.sun.com/javaee/5/docs/tutorial/doc/JSFIntro4.html#wp114963
embora, sinceramente, não goste dessa solução… se alguém conhecer uma melhor… informe-nos :lol:
mococaPJ 24 de dez. de 2006
blz…fiz o index e redirecionei para a minha pagina principal, que tem dois links que vao chamar a pagina inserir.jsp e buscar.jsp…ta gerando erro quando tento acessar estas paginass…
** a pagina principal é a seguinte:
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<title>Exemplo JSF</title>
</head>
<body>
<f:view>
<h:form>
<center>
<h1>Agenda</h1>
<br>
<h3>
<h:outputLink value="inserir.jsf">
<f:verbatim>Inserir</f:verbatim>
</h:outputLink>
<br><br>
<h:outputLink value="buscar.jsf">
<f:verbatim>Buscar</f:verbatim>
</h:outputLink>
</h3>
</center>
</h:form>
</f:view>
</body>
</html>
** o arquivo faces-config:
<faces-config>
<navigation-rule>
<from-view-id>/buscar.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/sucesso_busca.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/falha_busca.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/inserir.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/sucesso_insercao.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/falha_insercao.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>agenda</managed-bean-name>
<managed-bean-class>AgendaDB</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
*** arquivo web.xml :
& lt ; ? xml version = "1.0" encoding = "UTF-8" ? & gt ;
& lt ; web - app version = "2.4" xmlns = "http://java.sun.com/xml/ns/j2ee" xmlnssi = "http://www.w3.org/2001/XMLSchema-instance" xsi & #58;schemaLocation="http://java.sun.com/xml/ns/j2ee <a href="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" target="_blank" rel="nofollow">http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd</a>">
& lt ; context - param & gt ;
& lt ; param - name & gt ; com . sun . faces . verifyObjects & lt ; / param - name & gt ;
& lt ; param - value & gt ; true & lt ; / param - value & gt ;
& lt ; / context - param & gt ;
& lt ; context - param & gt ;
& lt ; param - name & gt ; com . sun . faces . validateXml & lt ; / param - name & gt ;
& lt ; param - value & gt ; true & lt ; / param - value & gt ;
& lt ; / context - param & gt ;
& lt ; context - param & gt ;
& lt ; param - name & gt ; javax . faces . CONFIG_FILES & lt ; / param - name & gt ;
& lt ; param - value & gt ; / WEB - INF / faces - config . xml & lt ; / param - value & gt ;
& lt ; / context - param & gt ;
& lt ; servlet & gt ;
& lt ; servlet - name & gt ; Faces Servlet & lt ; / servlet - name & gt ;
& lt ; servlet - class & gt ; javax . faces . webapp . FacesServlet & lt ; / servlet - class & gt ;
& lt ; load - on - startup & gt ; 1 & lt ; / load - on - startup & gt ;
& lt ; / servlet & gt ;
& lt ; servlet - mapping & gt ;
& lt ; servlet - name & gt ; Faces Servlet & lt ; / servlet - name & gt ;
& lt ; url - pattern & gt ; / faces /*& lt ; / url - pattern & gt ;
& lt ; / servlet - mapping & gt ;
& lt ; session - config & gt ; & lt ; session - timeout & gt ;
30
& lt ; / session - timeout & gt ; & lt ; / session - config & gt ; & lt ; welcome - file - list & gt ; & lt ; welcome - file & gt ;
index . jsp
& lt ; / welcome - file & gt ; & lt ; / welcome - file - list & gt ; & lt ; / web - app & gt ;
*** o erro gerado:
HTTP Status 404 - / exemplo - jsf / inserir . jsf
type Status report
message / exemplo - jsf / inserir . jsf
description The requested resource & # 40 ; / exemplo - jsf / inserir . jsf & # 41 ; is not available .
Apache Tomcat / 5.5.9
***** valeu
marcossousaPJ 26 de dez. de 2006
bom,
você está mapeando para usar uma url como:
localhost:8080/suaApp/faces/diretorio/index.jsp
mas está usando como:
localhost:8080/suaApp/diretorio/index.jsf
Aconselho antes de começar com JSF passar um pouco sobre Servlets…
:joia:
lllBlacklllPJ 16 de abr. de 2008
Use:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
Ao invés de
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>