【问题标题】:Creating AMP page with JSF使用 JSF 创建 AMP 页面
【发布时间】:2017-10-22 16:26:11
【问题描述】:

您好,我正在尝试使用 JSF 在我的网站上创建一个 AMP 页面,但遇到了这个问题

The mandatory attribute '⚡' is missing in tag 'html ⚡ for top-level html

在 JSF 中我得到了类似的东西

<!DOCTYPE html>
<html xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:o="http://omnifaces.org/ui"
    xmlns:of="http://omnifaces.org/functions"
    xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    >

我无法将这个字符“⚡”放在我的 html 页面上而不会出错

Caused by: javax.faces.view.facelets.FaceletException: Error Parsing /faces/public/pages/event/event-detail-amp.xhtml: Error Traced[line: 1] The markup in the document preceding the root element must be well-formed.
    at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:456) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.compiler.SAXCompiler.doMetadataCompile(SAXCompiler.java:439) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.compiler.Compiler.metadataCompile(Compiler.java:130) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.createMetadataFacelet(DefaultFaceletFactory.java:503) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$200(DefaultFaceletFactory.java:106) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:205) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:203) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:97) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:92) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_80]
    at com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:114) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:146) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:63) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:316) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:246) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:138) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:241) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    ... 45 more

我能做什么?

【问题讨论】:

  • 只需将amp 添加到您的html 标签中,例如&lt;html amp xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:o="http://omnifaces.org/ui" xmlns:of="http://omnifaces.org/functions" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" &gt;
  • 这确实有效,但我必须稍微改变一下。
  • 很高兴帮助@Victor

标签: jsf jsf-2 amp-html


【解决方案1】:

@Hackerman 解决方案对我有用,但我必须稍微改变一下

<html amp 
      xmlns:c="http://java.sun.com/jsp/jstl/core" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:o="http://omnifaces.org/ui" 
      xmlns:of="http://omnifaces.org/functions" 
      xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" 
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets" >

产生这个错误

08:20:22,576 ERROR [io.undertow.request] (default task-9) UT005023: Exception handling request to /contiego-app/faces/public/pages/event/event-detail-amp.xhtml: javax.servlet.ServletException: Error Parsing /faces/public/pages/event/event-detail-amp.xhtml: Error Traced[line: 4] Attribute name "amp" associated with an element type "html" must be followed by the ' = ' character.

所以我改成这个

<html amp="amp"
  xmlns:c="http://java.sun.com/jsp/jstl/core" 
  xmlns:f="http://java.sun.com/jsf/core" 
  xmlns:h="http://java.sun.com/jsf/html" 
  xmlns:o="http://omnifaces.org/ui" 
  xmlns:of="http://omnifaces.org/functions" 
  xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" 
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets" >

这似乎对我有用:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-19
    • 1970-01-01
    • 1970-01-01
    • 2018-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多