今天,自己所做的程序突然报错如下:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception thrown by getter for property: "userName" of bean: "org.apache.struts.taglib.html.BEAN" org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception thrown by getter for property: "userName" of bean: "org.apache.struts.taglib.html.BEAN" org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791) org.apache.jsp.userLogin_jsp._jspService(userLogin_jsp.java:120) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.jsp.JspException: Exception thrown by getter for property: "userName" of bean: "org.apache.struts.taglib.html.BEAN" org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:969) org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:121) org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102) org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:81) org.apache.jsp.userLogin_jsp._jspx_meth_html_005ftext_005f0(userLogin_jsp.java:181) org.apache.jsp.userLogin_jsp._jspx_meth_html_005fform_005f0(userLogin_jsp.java:142) org.apache.jsp.userLogin_jsp._jspService(userLogin_jsp.java:103) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 按照异常来看,应该是form的名字和JSP页面的名字不匹配导致的,可是看了函数和form以及JSP都一致,而且这些都是通过myeclipse自动生成的,应该没有问题。
于是调查看到form中的函数如下:
public String getUserName() { return userName.toLowerCase(); } 我想让所有的username都以小写的形式提供,但是,在form中却不可以,看来form只能是一个get、set原始值的,不能够进行任何过滤和处理,于是,就只能将代码改为:
public String getUserName() { return userName; } 修改之后,程序又可以正常运行了。
想使用简单的方法解决问题,却不可以。看来,以后还是尽量少修改自动生成的代码。