使用JSF2.0&的安装项目素面 [英] Setup Project with JSF2.0 & Prime Faces

查看:53
本文介绍了使用JSF2.0&的安装项目素面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用主面孔库设置JSF项目 当我运行此安装程序时,它显示以下错误

I am try to setup JSF project with prime faces library When I run this setup it shows be following error

org.apache.jasper.JasperException: javax.servlet.ServletException: null source
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:54
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

我无法找出背后的原因.以下是通过设置

I did not able to find out reason behind it .
following is by setup

以下是我包含在web-inf/lib中的库
1. jsf-api-2.0.3.jar
2. jsf-impl-2.0.3.jar
3. jstl-1.0.2.jar
4. primefaces-3.4.jar

Folloing are the library I included into web-inf/lib
1. jsf-api-2.0.3.jar
2. jsf-impl-2.0.3.jar
3. jstl-1.0.2.jar
4. primefaces-3.4.jar

以下是进入web.xml文件的内容

Following are the entrires into web.xml file

<?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.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param> 

    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

    <context-param>
        <param-name>primefaces.skin</param-name>
        <param-value>none</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>*.jsf</url-pattern>
    </servlet-mapping>

    <welcome-file-list> 
        <welcome-file>index.jsp</welcome-file>
     </welcome-file-list>

    <listener>
        <listener-class>
            com.nsf.ecap.web.base.ECapStartUpServlet
        </listener-class>
    </listener>

</web-app>


login.xhtml


login.xhtml

<h:body>   

 <CENTER>  

     <h:panel header="Login Form">    
     <h:Form>  
         <h:PanelGrid columns="2" cellpadding="2">  
         <h:outputLabel value="UserName" for="#{loginBBean.userInfo.username}"> </h:outputLabel>
         <h:inputText value="#{loginBBean.userInfo.username}" label="UserName">   </h:inputText>  
         <h:outputLabel value="Password" for="#{loginBBean.userInfo.password}"></h:outputLabel>  
         <h:inputSecret value="#{loginBBean.userInfo.password}"></h:inputSecret>  
         <h:commandButton value="Login" type="submit" action="#{loginBBean.doLogin}"></h:commandButton>   

        </h:PanelGrid>  

    <h:messages>
    </h:messages>



    </h:Form>
    </h:panel>
</CENTER>  
</h:body>  
</html> 


index.jsp


index.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">      
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>

  <body>        
    <jsp:forward page="jsp/login/login.jsf"/>      
  </body>
</html>

推荐答案

我的JSP'index.jsp'起始页"?请屏蔽/忽略/丢弃您正在阅读的教程. 这完全是在使您感到困惑,并教给您不良做法.

"My JSP 'index.jsp' starting page"? Please block/ignore/throwaway that tutorial you're reading now. It's only completely confusing you and teaching you bad practices.

关于您的库列表:

下面是我包含在web-inf/lib中的库

Folloing are the library I included into web-inf/lib

  1. jsf-api-2.0.3.jar
  2. jsf-impl-2.0.3.jar
  3. jstl-1.0.2.jar
  4. primefaces-3.4.jar

首先,JSTL版本是错误的.它至少应为JSTL 1.1或最好为1.2. EL(表达式语言,那些${}/#{})东西否则将无法正常工作.删除jstl-1.0.2.jar并放入 jstl-1.2.jar 就位.

First of all, the JSTL version is wrong. It should be at least JSTL 1.1 or preferably 1.2. The EL (expression language, those ${}/#{}) things would otherwise fail to work. Remove jstl-1.0.2.jar and put jstl-1.2.jar in place.

看起来还不错.令您惊讶的是,您使用的JSF API/impl版本已有2年以上,而您的PrimeFaces版本却比较新(不到2周).我将那些JSF API/impl版本也调整为最新可用.当前已经在

Further it looks okay. It only surprises me that you've more than 2 years old JSF API/impl versions while you've a fairly recent (less than 2 weeks) PrimeFaces version. I'd align those JSF API/impl versions as well to be the latest available. It's currently already at 2.1.13 (note: it's now composed of only one JAR file javax.faces.jar instead of two JAR files).

关于您的web.xml:

<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">

这已声明符合Servlet 2.5规范,已有6年的历史了.您确定您正在运行这样一个过时的容器吗?考虑到JSF和JSTL库的存在,我假设您正在使用Tomcat.当前的Tomcat版本7.x已经存在2年多了,并且与Servlet 3.0兼容.您应该声明web.xml以匹配目标容器的最高支持版本.

This is declared conform Servlet 2.5 spec which is over 6 years old already. Are you sure that you're running such an outdated container? Given the presence of the JSF and JSTL libraries, I assume that you're using Tomcat. The current Tomcat version, 7.x, exist more than 2 years already and is Servlet 3.0 compatible. You should declare your web.xml to match the highest supported version of the target container.

<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">

此外,那些javax.faces.STATE_SAVING_METHODjavax.faces.DEFAULT_SUFFIX条目已经代表了默认值.只需摆脱它们以将噪音降至最低.

Further, those javax.faces.STATE_SAVING_METHOD and javax.faces.DEFAULT_SUFFIX entries represent the default values already. Just get rid of them to minimize noise.

关于您的login.xhtml:

<h:Form>  
     <h:PanelGrid columns="2" cellpadding="2">  

标签名称区分大小写. <h:Form><h:PanelGrid>根本不存在.是<h:form><h:panelGrid>.

Tag names are case sensitive. The <h:Form> and <h:PanelGrid> doesn't exist at all. It are <h:form> and <h:panelGrid>.

<CENTER>  

虽然不是立即有问题,但是自1998年以来,已弃用此HTML元素,而使用CSS.同样,以大写字母代替<center>来看待它,这对于90年代以前的HTML风格来说是非常典型的,这不会给我留下您正在阅读最新,最正确的书籍/教程来学习Web开发的印象.您应该确保您的学习资源是最新的.

While not immediately a problem, but this HTML element is deprecated since 1998 in favor of CSS. Also, seeing it in uppercased flavor instead of <center>, which is very typical for pre-90's HTML style, doesn't give me the impression that you're reading the most recent and right books/tutorials to learn web development. You should assure that your learning resources are up to date.

关于您的index.jsp:这完全没有用.完全将其删除.只需将您的web.xml更改为

As to your index.jsp: this is completely useless. Remove it altogether. Just change your web.xml from

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

<welcome-file-list> 
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

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

<welcome-file-list> 
    <welcome-file>login.xhtml</welcome-file>
</welcome-file-list>

,这样login.xhtml就会显示为首页"当您在网络浏览器中访问/时.请注意,您应该也不再需要*.jsf URL模式.

and this way login.xhtml will show up as "home page" when you access / in your webbrowser. Note that you shouldn't and don't need *.jsf URL pattern anymore.

  • Our JSF wiki page - at the bottom you can find decent JSF 2.0 resources

这篇关于使用JSF2.0&amp;的安装项目素面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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