JSf标签未呈现 [英] JSf tags not being rendered

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

问题描述

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

this is a question i've seen here but the solution posted didn't resolve my issue. Again i'm dealing with jsf 2.0 and i have 2 pages: login.xhtml and index.xhtml, i'm also using SpringSecurity for auth purposes. index.xhtml renders ok but login doesn't(page source shows jsf tags un-parsed). I already deactivated SpringSecurity to check wether or not it had something to do with my issue but no luck...i really don't know what' wrong with my code (2 days straight trying to figure it out), so any help would be GREATLY appreciated. Here's my code:

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的一部分

part of 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>

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

Any ideas? thanks a lot!

推荐答案

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

page source shows jsf tags un-parsed

可能有2个原因:

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

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

<html>标记中缺少JSF组件的xmlns声明,因此将其视为纯文本.

The xmlns declarations for JSF components are missing in <html> tag, thus it was treated as plaintext.

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

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