java - Spring MVC @RequestMapping to return nothing, simply close -
i'm working on jsp gathers info , after it's submitted page closes , goes confirmation page. don't want confirmation page. after clicking submit on jsp, want window close. return value on controller needs value. can put in there allow end? controller:
@controller //@sessionattributes({"resultboard", "filterboard"}) public class newemployeecontroller { newemployeeservice newempservice; @autowired public newemployeecontroller(newemployeeservice service){ this.newempservice = service; } @requestmapping(value = "newempinput", method = requestmethod.get) public string promptemployee(model model) { //jsp can reference 1 object, need reference many objects. put many classes inside employeeformwrapper wrapper class. model.addattribute("myform", new employeeformwrapper()); return "newempinput"; } @requestmapping(value = "newempinput", method = requestmethod.post) public string newemployee(@modelattribute("myform") employeeformwrapper myform) { newemployeevm employee = myform.getemployee(); clientvm client = myform.getclient(); projectvm project = myform.getproject(); system.out.println("employee = " + employee.getfirstname() + " " + employee.getlastname()); system.out.println("client = " + client.gettext()); system.out.println("project = " + project.gettext()); newempservice.savenewemployee(employee); return "confirmnewemp"; } }
changed method in java controller return void. added script jsp:
<script type="text/javascript"> function closewindow() { window.close(); } </script>
and updated first line of form in jsp this:
<form:form commandname="employee" modelattribute="employee" onsubmit="closewindow()">
my submit button in jsp stays same:
<p> <input type="submit" value="submit"> </p>
and works. thanks.
Comments
Post a Comment