我是Struts的新手,必须学习它才能上班。我收到HTTP STATUS 500类型的错误。特别是,struts框架抛出了一个异常,该异常创建了SearchEventsForm类。
我在此类中找不到错误:
package it.mercury.form;
import org.apache.struts.action.ActionForm;
public class SearchEventsForm extends ActionForm{
/**
*
*/
private static final long serialVersionUID = 1L;
private String tipoprovenienza=null;
private String provenienza=null;
private String categoria=null;
private String giornoinizio=null;
private String meseinizio=null;
private String annoinizio=null;
private String giornofine=null;
private String mesefine=null;
private String annofine=null;
public String getProvenienza() {
return provenienza;
}
public void setProvenienza(String nomeProvenienza) {
this.provenienza = nomeProvenienza;
}
public String getTipoProvenienza() {
return tipoprovenienza;
}
public SearchEventsForm(String tipoProvenienza,String nomeProvenienza, String categoria, String giornoInizio, String meseInizio,
String annoInizio, String giornoFine, String meseFine, String annoFine) {
super();
this.tipoprovenienza = tipoProvenienza;
this.provenienza=nomeProvenienza;
this.categoria = categoria;
this.giornoinizio = giornoInizio;
this.meseinizio = meseInizio;
this.annoinizio = annoInizio;
this.giornofine = giornoFine;
this.mesefine = meseFine;
this.annofine = annoFine;
}
public void setTipoProvenienza(String tipoProvenienza) {
this.tipoprovenienza = tipoProvenienza;
}
public String getCategoria() {
return categoria;
}
public void setCategoria(String categoria) {
this.categoria = categoria;
}
public String getGiornoInizio() {
return giornoinizio;
}
public void setGiornoInizio(String giornoInizio) {
this.giornoinizio = giornoInizio;
}
public String getMeseInizio() {
return meseinizio;
}
public void setMeseInizio(String meseInizio) {
this.meseinizio = meseInizio;
}
public String getAnnoInizio() {
return annoinizio;
}
public void setAnnoInizio(String annoInizio) {
this.annoinizio = annoInizio;
}
public String getGiornoFine() {
return giornofine;
}
public void setGiornoFine(String giornoFine) {
this.giornofine = giornoFine;
}
public String getMeseFine() {
return mesefine;
}
public void setMeseFine(String meseFine) {
this.mesefine = meseFine;
}
public String getAnnoFine() {
return annofine;
}
public void setAnnoFine(String annoFine) {
this.annofine = annoFine;
}
}
struts-config.xml是:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
....
<form-beans>
<form-bean name="searchEventsForm" type="it.mercury.form.SearchEventsForm"/>
</form-beans>
<action-mappings>
<action
path="/searchEvents"
type="it.mercury.action.SearchEventsAction"
scope="request"
name="searchEventsForm"
validate="false"
input="/search.jsp">
<forward name="Success" path="/jsp/search.jsp"/>
<forward name="Failure" path="/jsp/errors/error.jsp"/>
</action>
</action-mappings>
</struts-config>
根本原因:
HTTP Status 500 – Internal Server Error
Type Exception Report
Message javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception creating bean of class it.mercury.form.SearchEventsForm under form name searchEventsForm
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception creating bean of class it.mercury.form.SearchEventsForm under form name searchEventsForm
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception creating bean of class it.mercury.form.SearchEventsForm under form name searchEventsForm
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838)
org.apache.jsp.jsp.search_jsp._jspService(search_jsp.java:155)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts.chain.commands.servlet.PerformForward.handleAsForward(PerformForward.java:113)
org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:96)
org.apache.struts.chain.commands.AbstractPerformForward.execute(AbstractPerformForward.java:54)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
javax.servlet.jsp.JspException: Exception creating bean of class it.mercury.form.SearchEventsForm under form name searchEventsForm
org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:536)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:503)
org.apache.jsp.jsp.search_jsp._jspx_meth_html_005fform_005f0(search_jsp.java:230)
org.apache.jsp.jsp.search_jsp._jspx_meth_html_005fhtml_005f0(search_jsp.java:187)
org.apache.jsp.jsp.search_jsp._jspService(search_jsp.java:142)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts.chain.commands.servlet.PerformForward.handleAsForward(PerformForward.java:113)
org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:96)
org.apache.struts.chain.commands.AbstractPerformForward.execute(AbstractPerformForward.java:54)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
注意在服务器日志中可以找到根本原因的完整堆栈跟踪。
Apache Tomcat(TomEE)/8.5.20(7.0.4)