首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

Struts开发错误-2

2013-09-11 
Struts开发异常-2HTTP Status 500 - type Exception reportmessage description The server encountered a

Struts开发异常-2
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /form/user.jsp at line 1310: <div style="border: 1px dashed red">${message }</div>11: <html:form action="/user">12: username : <html:text property="user.name"/><br/>13: userpwd : <html:text property="userinfo.pwd"/><br/>14: <html:submit value="LOGIN"/>15: </html:form>16: </body>Stacktrace:org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)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: No getter method for property userinfo.pwd of bean org.apache.struts.taglib.html.BEANorg.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)org.apache.jsp.form.user_jsp._jspService(user_jsp.java:86)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:386)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: No getter method for property userinfo.pwd of bean org.apache.struts.taglib.html.BEANorg.apache.struts.taglib.TagUtils.lookup(TagUtils.java:973)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.form.user_jsp._jspx_meth_html_005ftext_005f1(user_jsp.java:162)org.apache.jsp.form.user_jsp._jspx_meth_html_005fform_005f0(user_jsp.java:112)org.apache.jsp.form.user_jsp._jspService(user_jsp.java:76)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:386)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)

?

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.

Apache Tomcat/6.0.32

-------------------------------------------------------------

分析了很多原因~

这报错的原因是:ActionForm 的实现中和JSP不统一。因为 userinfo.pwd 会被解析为 getUserinfo.getPwd 这样的嵌套语句,这些和Actionform中是统一的,这是面向对象的一个特征之一~

看来得注意统一性问题,当然,透彻了解Struts 标签库原理才是,最终的办法~

?

以下是错误出错比对~

这是JSP中的 Struts 标签?

11: <html:form action="/user">
12: username : <html:text property="user.name"/><br/>
13: userpwd : <html:text property="userinfo.pwd"/><br/>
14: <html:submit value="LOGIN"/>
15: </html:form>

?

这是ActionForm 定义

/*
?* Generated by MyEclipse Struts
?* Template path: templates/java/JavaClass.vtl
?*/
package com.yourcompany.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import com.entity.Userinfo;

/**
?* MyEclipse Struts
?* Creation date: 09-20-2011
?*
?* XDoclet definition:
?* @struts.form name="userForm"
?*/
public class UserForm extends ActionForm {
?/*
? * Generated fields
? */

?/** user property */
?private Userinfo user;

?/*
? * Generated Methods
? */

?/**
? * Method validate
? * @param mapping
? * @param request
? * @return ActionErrors
? */
?public ActionErrors validate(ActionMapping mapping,
???HttpServletRequest request) {
??// TODO Auto-generated method stub
??return null;
?}

?/**
? * Method reset
? * @param mapping
? * @param request
? */
?public void reset(ActionMapping mapping, HttpServletRequest request) {
??// TODO Auto-generated method stub
?}

?/**
? * Returns the user.
? * @return Userinfo
? */
?public Userinfo getUser() {
??return user;
?}

?/**
? * Set the user.
? * @param user The user to set
? */
?public void setUser(Userinfo user) {
??this.user = user;
?}
}


我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行