JSF2 /…registerHostUser.xhtml @9,9 <h:head> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: head

非 Y 不嫁゛ 提交于 2019-12-01 21:24:32

Not sure how exactly this is caused and how exactly Maven plays a role since I don't use it, but I see at least three potential causes:

  1. You have JSF 1.x libraries in your /WEB-INF/lib or elsewhere in classpath. Remove it (or instruct Maven to not include them). Glassfish 3 already ships with builtin JSF 2.x libraries. The <h:head> was namely introduced in JSF 2.0 and is thus absent in JSF 1.x.

  2. The FaceletViewHandler declaration in faces-config.xml is entirely superfluous. Remove it. This is only mandatory when you're using JSF 1.x. JSF 2.x uses by default Facelets. If you did add it because you couldn't get Facelets to run, then the whole problem is definitely caused by cause #1 (and then remove any Facelets 1.x libraries as well).

  3. The web.xml is not been declared as Servlet 3.0. I'm not sure how Glassfish acts on this with regard to the provided JSF implementation, but you should be declaring Servlet 3.0 whenever the container supports it.

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app
        xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        id="Your_Webapp_ID" version="3.0">
    
        <!-- Config here -->
    
    </web-app>
    

    Also the com.sun.faces.expressionFactory param is entirely superfluous with Servlet 3.0 since it is already the Glassfish-default one.


Unrelated to the concrete problem, I recommend to bring the FacesServlet mappings to a minimum. Stick to the *.xhtml one and get rid of the others.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!