首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

struts中的数据验证功能报java.lang.NullPointerException

2014-01-26 
用struts,在视图上有一个用户名和密码的输入框,和提交按钮,我的LogonContentForm.java里已经写了相应的程序

用struts,
  在视图上有一个用户名和密码的输入框,和提交按钮,
  我的LogonContentForm.java里已经写了相应的程序,
  但是为什么我运行时,什么也不输,还是出现这个错误
  HTTP Status 500 -
 
  --------------------------------------------------------------------------------
 
  type Exception report
 
  message
 
  description The server encountered an internal error () that prevented it from fulfilling this request.
 
  exception
 
  java.lang.NullPointerException
  org.apache.struts.tiles.xmlDefinition.FactorySet.getDefinition(FactorySet.java:156)
  org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper.getDefinition(ComponentDefinitionsFactoryWrapper.java:124)
  org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:180)
  org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:341)
  org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
  org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
  org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
  org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
 
  note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
 
 
  --------------------------------------------------------------------------------
 
  Apache Tomcat/5.0.28
 
 
  _____________________________LogonContentForm.java程序
  package com.yourcompany.struts.form;
 
  //import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.*;
  import org.apache.struts.action.*;
  //import org.apache.struts.action.ActionErrors;
  //import org.apache.struts.action.ActionForm;
  //import org.apache.struts.action.ActionMapping;
 
 
  public class LogonContentForm extends ActionForm {
  private String userName;
  private String userPassword;
 
  public ActionErrors validate(
  ActionMapping mapping,
  HttpServletRequest request) {
  ActionErrors errors=new ActionErrors();
 
  if(userName==""||userName.length()<1)
  errors.add("userName",new ActionError("addressbook.logo.no.username.error"));
 
  return errors;
  }
 
  public void reset(ActionMapping mapping, HttpServletRequest request) {
  this.userName=null;
  // TODO Auto-generated method stub
  }
 
  public String getUserName() {
  return userName;
  }
 
  public void setUserName(String userName) {
  this.userName = userName;
  }
 
 
  public String getUserPassword() {
  return userPassword;         

热点排行