专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Java Exception

页面用<html:errors/>有什么限制?为什么我的会出错?

发布时间:2010-06-05 12:34:16 文章来源:www.iduyao.cn 采编人员:星星草

页面
  <%@ page contentType="text/html; charset=GBK" language="java" %>
 
  <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
  <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
  <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
  <%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
 
 
  <html>
  <head>
  <title>
  登录
  </title>
  </head>
  <body bgcolor="#ffffff">
  <html:errors property="org.apache.struts.action.GLOBAL_MESSAGE"/>
  <html:form action="/adminLogin.do" focus="userName">
  <html:text property="userName" size="16" maxlength="16"/>
  <bean:message key="form.userName.length" />
  <br>
  <html:submit property="submit" value="Submit"/>
  </html:form>
  </body>
  </html>
 
 
  =====================
  在FormBean里
  package Bean;
 
  import org.apache.struts.action.*;
  import javax.servlet.http.*;
 
  public class AdminLoginForm extends ActionForm {
  private String userName;
  public void setUserName(String userName) {
  this.userName = userName;
  }
  public String getUserName() {
  return userName;
  }
  public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
  ActionErrors errors = new ActionErrors();
  try{
  if ( (userName == null) || (userName.length() < 1))
  errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("form.userName.length"));
  }
  catch(Exception e){
  System.out.println("======here");
  }
  return errors;
  }
 
  public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
  this.userName=null;
  }
  }
 
  为什么我在文本框不输入任何东西就提交,就会出现这种错误提示
  --------------------------------------------------------------------------------
 
  type Exception report
 
  message Internal Server Error
 
  description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
 
  exception
 
  java.lang.ClassCastException
  at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
  at org.apache.jsp.Admin_0005flogin$jsp._jspService(Admin_0005flogin$jsp.java:80)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)     

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: