Creazione di un semplice progetto java maven su jboss application server e supporto JSF in Intellij [duplicate]


Questa domanda ha già una risposta qui:

Sono abbastanza nuovo nel mondo Java, quindi potrei non essere così preciso nella mia domanda. Sto cercando di creare un semplice progetto maven che supporti jsf in Intellij.

Il processo che ho seguito è il seguente:

  1. Crea un nuovo progetto
  2. Maven con archetype maven-archetype-quickstart(maven 3), scegliendo GroupId e ArtifactId
  3. Dopo che il progetto è stato creato fare clic destro sul progetto- > Aggiungi supporto Framework
  4. Scelgo Java EE (Java EE 8)->Applicazione Web (versioni 4.0) ->JSF (1.2)->Icefaces,Openfaces,Primefaces,Richfaces
  5. Quindi aggiungere Configurazione->Creare un nuovo server Jboss locale (7.5.0.Finale-redhat-21) e nella distribuzione aggiungere nuovo artefatto- > myproject: war exploded

Dopo tutti questi ho la seguente struttura:

Struttura generale

Nell'indice.xhtml Ho:

<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
   <f:view>
      <h:outputLabel value="Hello, world"/>
   </f:view>
</html>

E in pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>mygroupid</groupId>
  <artifactId>artifactid</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>artifactid</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

E nel web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <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>*.xhtml</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

Quando lo eseguo quello che mi aspetterei è una pagina html che ha nel corpo "Hello World" ma quello che ottengo è l'xhtml senza che il JSF sia stato renderizzato.

Qualsiasi aiuto sarebbe apprezzato

Author: BalusC, 2018-09-24

1 answers

Nel caso in cui qualcun altro abbia lo stesso problema. Ciò che è stato risolto è cambiare lo spazio dei nomi nel tag html, ad esempio xmlns:h="http://xmlns.jcp.org/jsf/html" a xmln: h="http://java.sun.com/jsf/html" e xmlns:ui="http://xmlns.jcp.org/jsf/facelets" a xmlns: ui="http://java.sun.com/jsf/facelets"

<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
   <f:view>
      <h:outputLabel value="Hello, world"/>
   </f:view>
</html>
 0
Author: Symeon Mattes, 2018-09-24 12:40:58