javax.servlet.ServletException: Could not find Errors instance for bean 'report' in request: add the Errors model to your ModelAndView via errors.getModel()
org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:758)
org.apache.jsp.WEB_002dINF.views.report_jsp._jspSe rvice(report_jsp.java:373)...
How can I fix this? I'm trying to create a basic MVC app with the SimpleFormController following the MVC-step-by-step documents. I've searched all over the Net and on these boards and I've found nothing that works.
------------------------------------------------
/*
* ReportFormController.java
*
* Created on January 30, 2005, 7:10 PM
*/
package com.spacepirates.ispreport;
import org.springframework.web.servlet.mvc.SimpleFormCont roller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;
import org.springframework.validation.BindException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.text.SimpleDateFormat;
/**
*
* @author scott
*/
public class ReportFormController extends SimpleFormController {
/** Logger for this class and subclasses */
protected final Log logger = LogFactory.getLog(getClass());
private ReportManager reportManager;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd @ HH:mm:ss z");
public ModelAndView onSubmit(Object command, BindException errors)
throws Exception {
String now = (new java.util.Date()).toString();
Map myModel = new HashMap();
myModel.put("now", now);
myModel.put("reports", getReportManager().getReports());
return new ModelAndView(new RedirectView(getSuccessView()),errors.getModel());
}
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
Report theReport = new Report();
// set properties to some defaults... could be done in the Report class I suppose.
theReport.setAddress("66.220.3.178");
theReport.setIsp("China Telecom");
theReport.setLocation("Shanghai");
//theReport.setReporter("worker");
theReport.setStatus("unreachable");
java.util.Date now = new java.util.Date();
theReport.setDateReported(sdf.format(now));
return theReport;
}
public ReportManager getReportManager() {
return reportManager;
}
public void setReportManager(ReportManager reportManager) {
this.reportManager = reportManager;
}
}


Reply With Quote