What to do when JSF tags do not become HTML

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

Event: JSF tag is displayed as it is without becoming HTML

I made a JSF project and wrote XHTML immediately, but ... JSF tags are output as they are スクリーンショット 2020-07-21 22.53.37.png

index.xhtml


<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core">
<head>
    <title>What to do when JSF tags do not become HTML</title>
</head>
<body>
  <h3>What to do when JSF tags do not become HTML</h3>
  h:I tried to write a checkbox with selectBooleanCheckbox
  <div>
    <h:selectBooleanCheckbox id="checkBox" value="false" />
    <h:outputLabel for="checkBox" value="Checkbox"/>
  </div>
</body>
</html>

Cause: The URL definition in web.xml and the URL used do not match

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

WEB-INF/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>tryJsf</display-name>
...abridgement...
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
</web-app>

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

Action 1: Match the URL to use with web.xml

If you use http: //xxxxxx/ {display-name} /index.xhtml, it will be displayed properly. スクリーンショット 2020-07-21 22.49.16.png

Action 2: Match the URL that uses web.xml

Modify web.xml, rebuild and rerun

WEB-INF/web.xml


...abridgement...
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
</web-app>

スクリーンショット 2020-07-21 22.59.39.png

Recommended Posts

What to do when JSF tags do not become HTML
What to do when debugging "Source not found"
What to do when javax.batch.operations.JobStartException occurs
What to do when Method not found in f: ajax
What to do when a javax.el.PropertyNotWritableException occurs
What to do when the changes in the Servlet are not reflected
[Rails] What to do when rails s does not respond or does not stop
What to do when you become a Problem During Content Assist
What to do when undefined method ʻuser_signed_in?'
What to do when javax.el.ELException: Not a Valid Method Expression: appears when the JSF screen is displayed
What do you use when converting to String?
What to do when IllegalStateException occurs in PlayFramework
<f: ajax> Unable to attach <f: ajax> to non-ClientBehaviorHolder What to do when you become a parent
What to do when the value becomes null in the second getSubmittedValue () in JSF Validator
What to do when rails db: seed does not reflect in the database
[Grails] Error occurred running What to do when the Grails CLI does not start
What to do when is invalid because it does not start with a'-'
What to do when The SSL certificate has expired
What to do if ClassNotFoundException occurs when starting Tomcat
What to do when a null byte error occurs
What to do when rails creates a 〇〇 2.rb file
Error ExecJS :: RuntimeUnavailable: What to do when it occurs
ParseException: What to do when Unparseable date is reached
What to do when routing settings do not work after building Docker environment with Laravel
What to do when it becomes Unable to find CDI BeanManager.
What to do when you launch an application with rails
What to do if audio is not available on discordrb
What to check when rails db: migration does not pass
What to do if FacesMessage is set but not displayed
What to do when Cannot apply expression operators to method binding
What to do when Cannot format given Object as a Date in convertDateTime of JSF
What to do when a could not find driver appears when connecting to a DB in a Docker environment
Bluemix Infrastructure VPN does not connect because it does not support NPAPI! What to do when [Mac]
What to do when Rails on Docker does not reflect controller changes in the browser
What to do when "relation" hibernate_sequence "does not exist" in the ID column of PostgreSQL + JPA
[Ubuntu 20.04] What to do if the external monitor is not recognized
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
[Rails] What to do if data is not registered in DB
java.security.InvalidKeyException: What to do when Illegal key size or default parameters
What to do after Vagrant install
[Rails 5] [Turbolinks] What to do when JS does not work due to page transition or browser back
[Logback] What to do if unnecessary files do not disappear during rotation
What to do if the app is not created with the latest Rails version installed when rails new
What to do when you run into a docker-compose node_modules problem
What to do if you get "Changes not staged for commit:" when you git status after git add.
What to do if Operation not permitted is displayed when you execute a command in the terminal
[IOS] What to do when the image is filled with one color
What to do if changes are not reflected after automatic deployment to EC2
What to do if the background image is not applied after deployment
What to do if the prefix c is not bound in JSP
What to do when CentOS cannot be started with VirtualBox on Catalina
What to do when "npm ERR! Code ENOSELF" is displayed after npm install
What to do when Blocked Host: "host name" appears in Ruby on Rails
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if an error occurs when nokogiri enters when bundle install
What to do if deployment fails on Heroku (Ruby app not detected)
Notes on what to do when EC2 is set up with t2.micro
What to do if tomcat process remains when tomcat is stopped in eclipse
What to do if you get an error when you hit Heroku logs
What to do when "call'Hoge.connection' to establish a connection" appears on rails c
Notes on what to do when a WebView ClassNotFoundException occurs in JavaFX 12