dimanche 23 août 2020

index.xhtml resource not found in JSF i tried with placing the file under webapp folder but still error

Project overview primefaces.jpg[] 2

error.jpg

i have created a maven simple archetype project.then through project facelets added jsf dynamic web project and wildfly server . when i run it gives resource not found but i have put my index.xhtml in the correct place . Can anyone please let me know where i did wrong .

...

index.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://primefaces.org/ui">
  <h:head>
  </h:head>
  <h:body>
    #{helloController.showHello()}
  </h:body>
</html>

HelloController.java

package com.test; import javax.faces.bean.ManagedBean;

@ManagedBean public class HelloController {

public String showHello() {
    return "hello from managed bean";
}

}

.......

web.xml

<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <display-name>TestDemo</display-name>
  <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>

  </welcome-file-list>
  

.............

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>site.test</groupId>
  <artifactId>TestDemo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <dependencies>
    <dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>8.0</version>
</dependency>
<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.faces</artifactId>
    <version>2.2.9</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>
  </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
            </plugin>
        </plugins>
    </build>
    
</project>



Aucun commentaire:

Enregistrer un commentaire