Struts 报错及其处理

今天,自己所做的程序突然报错如下:

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;
 }
修改之后,程序又可以正常运行了。
想使用简单的方法解决问题,却不可以。看来,以后还是尽量少修改自动生成的代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值