您好我试图在我的网站上用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"
>
我无法将这个角色放在一起#34;⚡&#34;在我的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
我该怎么办?
答案 0 :(得分:0)
@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" >
这似乎对我有用:)