简单的原理应用程序不工作 [英] Simple primefaces application not working

查看:134
本文介绍了简单的原理应用程序不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用键盘构建简单的JSF应用程序,但是不知何故,原理组件没有正确渲染。我不明白出了什么问题。



我正在尝试显示以下Facelet文件:

  html xmlns =http://www.w3.org/1999/xhtml
xmlns:ui =http://java.sun.com/jsf/facelets
xmlns:h =
xmlns:f =http://java.sun.com/jsf/core
xmlns:p =http:// primefaces.prime.com.tr/ui\">
< h:head>
< link type =text / css
rel =stylesheet
href =/ Themes / primefaces-dot-luv / theme.css/>
< / h:head>
< h:body>
< p:spinner value =100style =height:10px/>
< br />
< p:button value =Navigate>< / p:button>
< / h:body>
< / html>

我正在使用eclipse在tomcat服务器上运行应用程序。当我运行应用程序并在浏览器(Firefox)中查看页面源时,我得到以下来源:

 < html xmlns = http://www.w3.org/1999/xhtmlxmlns:p =http://primefaces.prime.com.tr/ui> 
< head>
< link type =text / css =stylesheethref =Themes / primefaces-dot-luv / theme.css/>
< / head>
< body>
< p:spinner value =100style =height:10px>< / p:spinner>
< br />
< p:button value =Navigate>< / p:button>
< / body>
< / html>

我认为PrimeFaces组件没有正确渲染。其他JSF标签如< h:head> < h:body> 正确转换为<$ c元素分别为$ c>< head> 和< body>



以下是我的项目结构: p>



我的 web.xml 如下所示:

 <?xml version =1.0encoding =UTF-8?> 
< web-app xmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexmlns =http://java.sun.com/xml/ns/javaeexmlns :web =http://java.sun.com/xml/ns/javaee/web-app_2_5.xsdxsi:schemaLocation =http://java.sun.com/xml/ns/javaee http:// java.sun.com/xml/ns/javaee/web-app_2_5.xsdid =WebApp_IDversion =2.5>
< display-name> HelloJSF< / display-name>
< welcome-file-list>
< welcome-file> index.jsp< / welcome-file>
< welcome-file> default.jsp< / welcome-file>
< / welcome-file-list>
< 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>
< context-param>
< param-name> primefaces.THEME< / param-name>
< param-value> none< / param-value>
< / context-param>
< context-param>
< description>状态保存方式:'client'或'server'(= default)。请参阅JSF规范2.5.2< / description>
< param-name> javax.faces.STATE_SAVING_METHOD< / param-name>
< param-value>客户端< / param-value>
< / context-param>
< context-param>
< param-name> javax.servlet.jsp.jstl.fmt.localizationContext< / param-name>
< param-value> resources.application< / param-value>
< / context-param>
< listener>
< listener-class> com.sun.faces.config.ConfigureListener< / listener-class>
< / listener>
< servlet-mapping>
< servlet-name> Faces Servlet< / servlet-name>
< url-pattern> *。jsf< / url-pattern>
< / servlet-mapping>
< servlet-mapping>
< servlet-name> Faces Servlet< / servlet-name>
< url-pattern> *。faces< / url-pattern>
< / servlet-mapping>
< / web-app>

我正在使用eclipse,tomcat服务器。 JSF 2和原理3库。


经过对整个项目的仔细检查后,我发现
网站没有任何课程。 Jar
本身已损坏。我下载了同样的jar三次,然后jar也
得到腐败。所以我下载了包含源和
二进制文件的zip文件,我的应用程序开始工作。



解决方案

p>尝试更改您的web.xml servlet映射:

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

Facelets Servlet正在处理您的xhtml的方法是查看浏览器接收的内容。如果它看起来像你的xhtml文件,那么你有错误的配置。


I am trying to build simple JSF application using primefaces but somehow primefaces components are not getting rendered properly. I dont understand what is going wrong.

I am trying to display following Facelet file :

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <link type="text/css" 
                rel="stylesheet"
                href="/Themes/primefaces-dot-luv/theme.css" />
    </h:head>
    <h:body>
        <p:spinner value="100" style="height: 10px" />
        <br/>
        <p:button value="Navigate"></p:button>
    </h:body>
</html>

I am using eclipse to run the app on tomcat server. When I run the application and view the page source in browser(firefox) I get following source :

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://primefaces.prime.com.tr/ui">
    <head>
        <link type="text/css" rel="stylesheet" href="Themes/primefaces-dot-luv/theme.css" />
    </head>
    <body>
        <p:spinner value="100" style="height: 10px"></p:spinner>
        <br />
        <p:button value="Navigate"></p:button>
    </body>
</html>

I think PrimeFaces components are not getting rendered properly. Other JSF tags like <h:head> and <h:body> are converted correctly to <head> and <body> elements respectively. Only tags starting with <p:> are not converted.

Following is my project structure :

My web.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>HelloJSF</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <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>
  <context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>none</param-value>
  </context-param>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
</web-app>

I am using eclipse , tomcat server. JSF 2 and primefaces 3 library.

Hi, After some close inspection of entire project I found out that primefaces jar dowlonaded from site did not had any classes. Jar itself was corrupt. I downloaded same jar thrice then also jar was getting corrupt. So I downloaded zip file containing source and binaries and my application started working.

解决方案

Try changing your web.xml servlet mapping:

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

The way to tell if the Facelets Servlet is processing your xhtml is to look at what the browser receives. If it looks like your xhtml file then you have something mis-configured.

这篇关于简单的原理应用程序不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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