Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS和Javascript不应用于从带有escape=”的h:outputText呈现的内容;假;_Javascript_Css_Jsf_Google Cloud Datastore - Fatal编程技术网

CSS和Javascript不应用于从带有escape=”的h:outputText呈现的内容;假;

CSS和Javascript不应用于从带有escape=”的h:outputText呈现的内容;假;,javascript,css,jsf,google-cloud-datastore,Javascript,Css,Jsf,Google Cloud Datastore,使用escape=“false”从h:outText呈现的内容不会绑定到适用于该页面的css或javascript。实际上,我正试图使用语法高亮显示工具在帖子中突出显示我的语法。文章存储在数据库中,并通过将escape属性设置为false,将其显示在带有h:outputText标记的JSF页面中。它按预期呈现页面,处理所有html标记,但不应用适用于该帖子中代码块的css或javascript。下面是我的jsf页面,它从数据库检索html并通过h:outputText标记显示。检索到的内容具有需

使用escape=“false”从h:outText呈现的内容不会绑定到适用于该页面的css或javascript。实际上,我正试图使用语法高亮显示工具在帖子中突出显示我的语法。文章存储在数据库中,并通过将escape属性设置为false,将其显示在带有h:outputText标记的JSF页面中。它按预期呈现页面,处理所有html标记,但不应用适用于该帖子中代码块的css或javascript。下面是我的jsf页面,它从数据库检索html并通过h:outputText标记显示。检索到的内容具有需要突出显示的语法

   <ui:composition 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"
        template="/templates/ui.xhtml">

 <ui:define name="head">
    <title>tekBytes-#{tutorialController.tut.title}</title>

<h:outputScript library="primefaces" name="jquery/jquery.js" />
<link href="/rainbow/themes/pastie.css" rel="stylesheet" type="text/css" />
<script src="/rainbow/rainbow.min.js"></script>
<script src="/rainbow/language/generic.js"></script>
<script src="/rainbow/language/java.js"></script>
<script src="/rainbow/language/css.js"></script>
  <script type = "text/javascript">
/*
 * do some jQuery magic on load
 */
$(document).ready(function() {
    function showHiddenParagraphs() {
        $("pre.hidden").fadeIn(500);
    }
    setTimeout(showHiddenParagraphs, 1000);
});

</script>
  </ui:define>
  <ui:define name="content">
  <div style="margin:20px">
  <h1>#{tutorialController.tut.title}</h1>
  <br/>
  <h:outputText value="#{tutorialController.tut.contentStr}" escape="false"/>
  </div>
  </ui:define>
</ui:composition>

tekBytes-#{tutorialController.tut.title}
/*
*在加载时执行一些jQuery魔术
*/
$(文档).ready(函数(){
函数showHiddenPages(){
$(“隐藏前”).fadeIn(500);
}
setTimeout(showHidden,1000);
});
#{tutorialController.tut.title}

在JSF2.0中,所有web资源文件,如css、图像或 JavaScript,应该放在“resources”文件夹中,在 web应用程序(与“web-INF”文件夹级别相同)


将您的js/css放入
resources/js
resources/css
文件夹中,并使用
访问它们。此处可能有许多地方存在潜在问题,请按顺序验证以下内容

    1) Check your CSS files are getting loaded by the browser 
by monitoring the request in developer tools on Firefox or chrome.

   https://developers.google.com/chrome-developer-tools/docs/overview?hl=fr

    2) check the source of your html to see if that looks 
fine and tags are not encoded etc. 

    3) verify your CSS to see it works and it doesn't have missing semicolon,
 brackets,quotes etc by adding it to a test html page on your machine.

我解决了这个问题。实际的问题是,存储在数据库中的html是通过p:editor生成的,p:editor在每一行的周围都放置了很多div标记,因此当它通过h:outputText标记呈现时,css或javascript无法解析适用于语法高亮显示的代码块,因为被包围的div和其他标签。所以我在将其存储到数据库之前删除了所有这些不必要的标签。谢谢大家的回复

<h:outputStylesheet name="css/language/css.js" />
    1) Check your CSS files are getting loaded by the browser 
by monitoring the request in developer tools on Firefox or chrome.

   https://developers.google.com/chrome-developer-tools/docs/overview?hl=fr

    2) check the source of your html to see if that looks 
fine and tags are not encoded etc. 

    3) verify your CSS to see it works and it doesn't have missing semicolon,
 brackets,quotes etc by adding it to a test html page on your machine.