Création d'un projet java maven simple sur le serveur d'applications jboss et le support JSF dans Intellij [dupliquer]
Cette question a déjà une réponse ici:
Je suis assez nouveau dans le monde Java, donc je ne suis peut-être pas si précis dans ma question. J'essaie de créer un projet maven simple qui prend en charge jsf dans Intellij.
Le processus que j'ai suivi est le suivant:
- Créer un nouveau projet Si vous avez besoin d'un outil de démarrage rapide, vous pouvez utiliser l'archétype maven-archetype-quickstart(maven 3), en choisissant GroupId et ArtifactId
- Une fois le projet créé, faites un clic droit sur le projet- > Ajouter un support de framework J'ai choisi Java EE (Java EE 8)->Application Web (versions 4.0) ->JSF (1.2)->Icefaces,Openfaces,Primefaces,Richfaces
- Puis Ajouter Configuration->Créer un nouveau Serveur Jboss Local (7.5.0.Final-redhat-21) et en déploiement ajouter nouvel artefact->myproject:guerre éclata
Après tout cela, j'ai la structure suivante:
Dans l'index.xhtml J'ai:
<?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>
Et en 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>
Et dans le 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>
Quand je l'exécute, ce à quoi je m'attendrais est une page html qui a dans le corps "Hello World" mais ce que j'obtiens est le xhtml sans que le JSF ait été rendu.
Toute aide serait appréciée
1 answers
Juste au cas où quelqu'un d'autre aurait le même problème. Ce qui a été résolu est de changer l'espace de noms dans la balise html, c'est-à-dire xmlns:h="http://xmlns.jcp.org/jsf/html" vers xmlns: h="http://java.sun.com/jsf/html" et xmlns: ui="http://xmlns.jcp.org/jsf/facelets" pour 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>