wowiesy
Aug 12th, 2007, 12:47 PM
I am testing a simple form which adds a record to a table in a database using this controller:
package dist.web;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.web.bind.ServletRequestDataBin der;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormCont roller;
import java.util.*;
import dist.dao.UomDao;
import dist.domain.*;
public class AddUomController extends SimpleFormController {
private UomDao uomDao;
static Logger logger = Logger.getLogger(ViewUomController.class);
public AddUomController(){
setFormView("adduom");
setSuccessView("addUomSuccess");
setBindOnNewForm(false);
setSessionForm(false);
setCommandName("uom");
setCommandClass(Uom.class);
}
public UomDao getUomDao() {
return uomDao;
}
public void setUomDao(UomDao uomDao) {
this.uomDao = uomDao;
}
protected ModelAndView onSubmit(Object command) throws Exception {
Uom uom = (Uom) command;
getUomDao().insertUom(uom);
Map model = new HashMap();
model.put(getCommandName(), uom);
return new ModelAndView(getSuccessView(),model);
}
I have views.properties defined as follows:
addUomSuccess.(class)=org.springframework.web.serv let.view.RedirectView
addUomSuccess.url=addUomSuccess.jsp
editUomSuccess.(class)=org.springframework.web.ser vlet.view.RedirectView
editUomSuccess.url=edituomsuccess.jsp
viewuom.(class)=org.springframework.web.servlet.vi ew.JstlView
viewuom.url=/WEB-INF/jsp/viewuom.jsp
adduom.(class)=org.springframework.web.servlet.vie w.JstlView
adduom.url=/WEB-INF/jsp/adduom.jsp
when i submit my form, I am presented with this page:
HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
Apache Tomcat/5.5.23
and the url on my browser is set to:
http://localhost:8080/dsrapp/app/addUomSuccess.jsp?uom=%5B+UOM+ID%3A+21%2CUOM%3A+UN IT%2FS%5D
when I check the database, the new entry I inserted is inserted. It's just that my redirect view isn't rendering properly.
I tried using "redirect:addUomSuccess.jsp" in the successview but I was also getting an error. I'm not really sure how to move forward. The other docs in the web I found, I also couldn't understand how to implement.
By the way, my addUomSuccess.jsp is under the /WEB-INF/jsp folder, together with the other jsp files that is the formview of the controller being tested here.
package dist.web;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.web.bind.ServletRequestDataBin der;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormCont roller;
import java.util.*;
import dist.dao.UomDao;
import dist.domain.*;
public class AddUomController extends SimpleFormController {
private UomDao uomDao;
static Logger logger = Logger.getLogger(ViewUomController.class);
public AddUomController(){
setFormView("adduom");
setSuccessView("addUomSuccess");
setBindOnNewForm(false);
setSessionForm(false);
setCommandName("uom");
setCommandClass(Uom.class);
}
public UomDao getUomDao() {
return uomDao;
}
public void setUomDao(UomDao uomDao) {
this.uomDao = uomDao;
}
protected ModelAndView onSubmit(Object command) throws Exception {
Uom uom = (Uom) command;
getUomDao().insertUom(uom);
Map model = new HashMap();
model.put(getCommandName(), uom);
return new ModelAndView(getSuccessView(),model);
}
I have views.properties defined as follows:
addUomSuccess.(class)=org.springframework.web.serv let.view.RedirectView
addUomSuccess.url=addUomSuccess.jsp
editUomSuccess.(class)=org.springframework.web.ser vlet.view.RedirectView
editUomSuccess.url=edituomsuccess.jsp
viewuom.(class)=org.springframework.web.servlet.vi ew.JstlView
viewuom.url=/WEB-INF/jsp/viewuom.jsp
adduom.(class)=org.springframework.web.servlet.vie w.JstlView
adduom.url=/WEB-INF/jsp/adduom.jsp
when i submit my form, I am presented with this page:
HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
Apache Tomcat/5.5.23
and the url on my browser is set to:
http://localhost:8080/dsrapp/app/addUomSuccess.jsp?uom=%5B+UOM+ID%3A+21%2CUOM%3A+UN IT%2FS%5D
when I check the database, the new entry I inserted is inserted. It's just that my redirect view isn't rendering properly.
I tried using "redirect:addUomSuccess.jsp" in the successview but I was also getting an error. I'm not really sure how to move forward. The other docs in the web I found, I also couldn't understand how to implement.
By the way, my addUomSuccess.jsp is under the /WEB-INF/jsp folder, together with the other jsp files that is the formview of the controller being tested here.