JSF h标签未显示 [英] JSF h tags not displaying

查看:112
本文介绍了JSF h标签未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Netbeans在Glassfish 3.1.2.2上部署Web应用程序,而我的h标签都没有显示在Web上.例如:

Using Netbeans to deploy a web app on Glassfish 3.1.2.2 and none of my h tags display on the web. For instance:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
    <head>
        <title>Draft Savvy Beers</title>
    </head>
    <h:form>
        <h:body>
            <h1>Search for beers</h1>
            <p><strong>Would you like to search for a beer?</strong>
                <h:inputText value="#{draftSavvyController.searchTerm}" />
                <h:commandButton value="#{draftSavvyController.searchforBeers}" /></p>
        </h:body>
    </h:form>
</html>

仅显示文本,不显示输入字段或按钮.使用普通的旧html显然会显示字段和按钮,但是我无法以这种方式访问​​我的控制器.这是我的web.xml:

displays only the text, no input field or button. Using plain old html shows the fields and buttons obviously, but I can't access my controller this way. Here is my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 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">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>login.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

让我知道是否可以提供更多信息.我对此很陌生...

Let me know if I can provide anymore info. I'm pretty new at this...

推荐答案

将此添加到您的web.xml:

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

我认为问题的原因在于请求没有通过FacesServlet传递.

I think the cause of the problem is that the request is not being passed through the FacesServlet.

页面URL与FacesServlet的url模式不匹配,因此它没有任何机会解析标签.

The page URL did not match the url-pattern of the FacesServlet, thus it had not any chance to parse the tags.

这篇关于JSF h标签未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆