简单的JSP Facelets页面中的java.lang.NullPointerException

时间:2014-03-06 06:18:34

标签: jsp jsf

我在netbeans ide中运行项目时遇到此错误。我刚刚使用了JSP-Facelets,但我没有得到输出..

**welcomeJSF.jsp**

  <%@page contentType="text/html" pageEncoding="UTF-8"%>

  <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
  <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">

  <f:view>
   <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Main Page</title>
      </head>
    <body>

        <h1><h:outputText value="Welcome to JavaServer Faces"/></h1>
        <br>
        <center>
        <table border="1" width="30%" cellpadding="3">
            <thead>
                <tr>
                    <th colspan="2">Login Here</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><h:outputText value="Name:"/></td>
                    <td><h:inputText id="name" required="true" requiredMessage="Enter    Name!!" autocomplete="False" maxlength="20" label="name" value="#{user.name}" /></td>
                </tr>
                <tr>
                    <td><h:outputText value="Password:"/></td>
                    <td><h:inputSecret id="password" required="true" requiredMessage="Enter Password" label="password" maxlength="20" value="#{user.password}" /></td>
                </tr>
                <tr>
                    <td><h:commandButton id="loginBtn" value="Login" type="submit" action="#{user.login}" /></td>
                    <td><h:commandButton id="resetBtn" value="Reset" type="reset" /></td>
                </tr>
                <tr>
                    <td colspan="2">Yet Not Registered!! <h:commandButton id="registerBtn" value="Register Here" type="submit" action="reg.jsp" /></td>
                </tr>
            </tbody>
         </table>
        </center>
        </body>
             </html>
      </f:view>

我的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>
    <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>*.jsp</url-pattern>
   </servlet-mapping>
  <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
    </dependency>
  <session-config>
    <session-timeout>
        30
    </session-timeout>
   </session-config>
  <welcome-file-list>
    <welcome-file>faces/welcomeJSF.jsp</welcome-file>
   </welcome-file-list>

   </web-app>

0 个答案:

没有答案