【问题标题】:JSf tags not being rendered [duplicate]JSf标签未呈现[重复]
【发布时间】:2011-02-15 12:39:08
【问题描述】:

这是我在这里看到的一个问题,但发布的解决方案并没有解决我的问题。我再次处理 jsf 2.0 并且我有 2 个页面:login.xhtml 和 index.xhtml,我还使用 SpringSecurity 进行身份验证。 index.xhtml 呈现正常,但登录没有(页面源显示未解析的 jsf 标签)。我已经停用 SpringSecurity 以检查它是否与我的问题有关,但没有运气......我真的不知道我的代码有什么问题(连续两天试图弄清楚),所以任何帮助都会非常感谢。这是我的代码:

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<!-- Spring Security -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring Security -->

<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>JSF2Example/index.xhtml</welcome-file>
</welcome-file-list>

login.xhtml 的一部分

<h:head>
    <title>Ejemplo JSF 2 AJAX</title>
</h:head>
<h:body>
       <h:form id="login">
        <h:panelGrid columns="2">
            <h:outputLabel for="Usuario" value="Usuario:"/>
            <h:inputText id="Usuario" value="#{loginBean.userName}" required="true"/>
            <h:outputLabel for="Password" value="Contraseña:"/>
            <h:inputSecret id="Password" value="#{loginBean.password}"        required="true"/>
        </h:panelGrid>
        <h:commandButton value="Ingresar" actionListener="#{loginBean.doLogin}"/>
        <h:messages/>
    </h:form>
</h:body>

有任何想法吗?非常感谢!

【问题讨论】:

    标签: jsf spring-security facelets


    【解决方案1】:

    页面源代码显示未解析的 jsf 标签

    这可能有两个原因:

    1. 页面URL与FacesServleturl-pattern不匹配,因此没有机会解析标签。

    2. &lt;html&gt; 标记中缺少 JSF 组件的 xmlns 声明,因此它被视为明文。

    【讨论】:

    • 您好 BalusC,感谢您的帮助。我确实解决了将 url 模式从 /faces/* 更改为 *.xhtml 的问题,旧模式以某种方式干扰了 Spring-Security 配置。
    • 这里也一样。不得不将其切换到 *.xhtml...
    猜你喜欢
    • 2011-03-20
    • 2013-04-21
    • 1970-01-01
    • 2011-01-13
    • 2013-10-06
    • 2012-12-01
    • 1970-01-01
    • 2018-01-08
    • 2015-01-20
    相关资源
    最近更新 更多