- 環境
- 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;
}
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>
を使っているから
対応方法 : <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>
<省略>