我输入了以下代码:
<h:outputStylesheet library="css" name="style.css" target="body" />问题是它给了我一个关于target="body“的错误,上面说:
The attribute target is not defined in the component outputStylesheet在html部分,如果html有以下内容:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">我怎样才能解决这个问题?
谢谢
发布于 2013-11-27 11:03:17
看看。它确实没有列出target属性。也许您与来自的那个混淆了。
默认情况下,<h:outputStylesheet>总是将重新定位到HTML<head>,原因很简单,因为在HTML<body>中有一个<style>或<link>元素是非法的。然而,默认情况下,<h:outputScript>的位置与声明位置完全相同。由它生成的<script>元素可以放置在HTML、<head>或<body>中的任何位置。通过将target属性设置为head (然后将出现在<head>中)或body (然后将出现在<body>末尾),您可以让JSF自动重新定位。
只要把它移开。如果target="body"理论上有效的话,它最终只会变成非法的HTML。
<h:outputStylesheet library="css" name="style.css" />无关的具体问题,资源库名称"css“在语义上是错误的。把它放在资源名中。
<h:outputStylesheet name="css/style.css" />另请参阅:
https://stackoverflow.com/questions/20240302
复制相似问题