[Java] How to respond when JSF tags are not HTML

1 minute read

-Environment -CentOS Linux release 7.8.2003 (Core) -Payara Server 5.194 -Eclipse IDE for Enterprise Java Developers.Version: 2020-03 (4.15.0)

Phenomenon: JSF tags are displayed as they are without being HTML

I created a JSF project and immediately wrote XHTML, but the JSF tags are output as is. ![Screenshot 2020-07-21 22.53.37.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/159761/fa8cd781-8633-c6f6-b0d1-(8037f2b1554e.png)


<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
    <title>Correspondence when JSF tag is not HTML</title>
  <h3>Correspondence method when JSF tag is not HTML</h3>
  I tried to write a check box with h:selectBooleanCheckbox
    <h:selectBooleanCheckbox id="checkBox" value="false" />
    <h:outputLabel for="checkBox" value="checkbox"/>

Cause: The URL definition in web.xml does not match the URL you are using

servlet-mapping defines how to specify the URL to access the web application. Introduction to Java EE Web System by Takashi Kawaba


<?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">
    <servlet-name>Faces Servlet</servlet-name>

If it is the definition of web.xml, it is displayed by http://xxxxxx/{display-name}/faces/index.xhtml However, this event failed because it was displayed at http://xxxxxx/{display-name}/index.xhtml.

Support 1: Match the URL to be used with web.xml

It is displayed properly when using http://xxxxxx/{display-name}/index.xhtml Screenshot 2020-07-21 22.49.16.png

Support 2: Match the URL using web.xml

Modify web.xml, rebuild and rerun


    <servlet-name>Faces Servlet</servlet-name>

![Screenshot 2020-07-21 22.59.39.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/159761/aa3a6667-d66e-1259-b4ea-(337db86de404.png)

Tags: ,