type Exception reportmessage java.lang.NullPointerExceptiondescription The server encountered an internal error that prevented it from fulfilling this request.exceptionorg.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:335)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root causejava.lang.NullPointerException
org.apache.jsp.words_005flist_jsp._jspService(words_005flist_jsp.java:118)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:335)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.12 logs.这个是异常,

解决方案 »

  1.   

    package com.sushe;
    import java.util.*;
    import java.sql.*;
    import java.text.*;public class words extends mysql_db
    {
    //定义成员变量
    private int WordsID;
    private String WordsTitle;
    private String WordsContent;
    private String WordsTime;
    private int UserID;
    private String strSql;
    //时间格式
    private SimpleDateFormat timeFormatter;

    public words()
    {
    this.WordsID = 0;
    this.WordsTitle = "";
    this.WordsContent ="";
    this.UserID = 0;
    timeFormatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    this.WordsTime = timeFormatter.format(new java.util.Date());
    this.strSql = "";
    }
    /*添加留言记录*/
    public boolean add_words()
    {
    this.strSql = "insert into words ";
    this.strSql = this.strSql + "(";
    this.strSql = this.strSql + "this.WordsTitle,";
    this.strSql = this.strSql + "this.WordsContent,";
    this.strSql = this.strSql + "this.WordsTime,";
    this.strSql = this.strSql + "this.UserID";
    this.strSql = this.strSql + ")";

    this.strSql = this.strSql + "values(";
    this.strSql = this.strSql + "'" + this.WordsTitle + "',";
    this.strSql = this.strSql + "'" + this.WordsContent + "',";
    this.strSql = this.strSql + "'" + this.WordsTime + "',";
    this.strSql = this.strSql + "'" + this.UserID + "'";
    this.strSql = this.strSql + ")"; boolean isAdd = super.exeSql(this.strSql);
    return isAdd;
    }
    /*获取某条留言信息 by WordsID*/
    public boolean init()
    {
    this.strSql = "select * from 'words' where WordsID=";
    this.strSql = this.strSql +"'"+ this.WordsID+"'";
    try
    {
    ResultSet rs = super.exeSqlQuery(strSql);
    if (rs.next())
    {
    this.WordsID = rs.getInt("WordsID");
    this.WordsTitle = rs.getString("WordsTitle");
    this.WordsContent = rs.getString("WordsContent");
    this.WordsTime = rs.getString("WordsTime");
    this.UserID = rs.getInt("UserID");
    return true;
    }
    else
    {
    return false;
    }
    }
    catch(Exception ex)
    {
    System.out.println(ex.toString());
    return false;
    }
    }
    /*显示所有留言*/
    public ResultSet show_all_words()
    {
    this.strSql = "select * from 'words'";
    ResultSet rs = null; try
    {
    rs = super.exeSqlQuery(this.strSql);
    }
    catch(Exception ex)
    {
    System.out.println(ex.toString());
    }
    return rs;
    }
    /*设置成员变量WordsID的值*/
    public void setWordsID(int WordsID)
    {
    this.WordsID = WordsID;
    }
    /*获取成员变量WordsID的值*/
    public int getWordsID()
    {
    return this.WordsID;
    }
    /*设置成员变量WordsTitle的值*/
    public void setWordsTitle(String WordsTitle)
    {
    this.WordsTitle = WordsTitle;
    }
    /*获取成员变量WordsTitle的值*/
    public String getWordsTitle()
    {
    return this.WordsTitle;
    }
    /*设置成员变量WordsContent的值*/
    public void setWordsContent(String WordsContent)
    {
    this.WordsContent = WordsContent;
    }
    /*获取成员变量WordsTitle的值*/
    public String getWordsContent()
    {
    return this.WordsContent;
    }
    /*设置成员变量WordsTime的值*/
    public void setWordsTime(String WordsTime)
    {
    this.WordsTime = WordsTime;
    }
    /*获取成员变量WordsTime的值*/
    public String getWordsTime()
    {
    return this.WordsTime;
    }
    /*设置成员变量UserID的值*/
    public void setUserID(int UserID)
    {
    this.UserID = UserID;
    }
    /*获取成员变量UserID的值*/
    public int getUserID()
    {
    return this.UserID;
    }
    }
    这是words.java文件,