LoginSignup
0
0

More than 3 years have passed since last update.

One or more resources have the target of 'head', but no 'head' component has been defined within the view.となった時の対応方法

Last updated at Posted at 2017-12-12
  • 環境
    • macOS Hight Sierra
    • Eclipse : Neon.3 Release (4.6.3)
    • GlassFish 4.1
    • Java : JDK1.8
    • JSF : 2.2

事象 : JSFでCSSを読み込んだはずなのに適用されなくてserver.logになんか出てた

修正前のXHTML
<?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:f="http://xmlns.jcp.org/jsf/core">
<head>
  <title>入力画面</title>
  <h:outputStylesheet library="css" name="base.css"/>
</head>
<body>
<h:form>
  <h:outputLabel>パスワードを入力して下さい。</h:outputLabel>
  <br />
  <h:inputText id="password" value="#{passwordBean.password}">
    <f:validateRequired />
    <f:validateLength minimum="3" maximum="10"></f:validateLength>
  </h:inputText>
  <h:message for="password" errorClass="error" />
<省略>
base.css
@CHARSET "UTF-8";
.error {
    color: red;
}

Screen Shot 2017-12-12 at 20.13.28.png

server.log
[2017-12-12T20:29:46.608+0900] [glassfish 4.1] [INFO] [jsf.non_displayed_message] [javax.enterprise.resource.webcontainer.jsf.renderkit] [tid: _ThreadID=32 _ThreadName=http-listener-1(2)] [timeMillis: 1513078186608] [levelValue: 800] [[
  WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=null[severity=(ERROR 2), summary=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.), detail=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.)]]]

原因 : <head>を使っているから

user interface - One or more resources has the target of 'head' but not 'head' component has been defined within the view - Stack Overflow

対応方法 : <h:head>を使う

修正後のXHTML
<?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:f="http://xmlns.jcp.org/jsf/core">
<h:head>
  <title>入力画面</title>
  <h:outputStylesheet library="css" name="base.css"/>
</h:head>
<省略>

Screen Shot 2017-12-12 at 20.19.48.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0