spring - Form POST submit "The request sent by the client was syntactically incorrect." -


i have no idea i've made mistake. i've been trying solve problem hours can't figure out... i'm getting http status 400 request sent client syntactically incorrect. while submiting form list of objects checkboxes each of objects. heres of code:

controller:

@requestmapping(value = "/admin/panel", method = requestmethod.get) public string adminpanel(locale locale, model model, form form,         httpservletrequest request) {     formwrapper wrapper = getformwrapper();     model.addattribute("listofobjects", wrapper);     model.addattribute("allcategories", dao.getcatslist());     return "web-inf/views/index/admin/home"; }   @requestmapping(value = "/admin/saveadmin", method = requestmethod.post) public string save(model model, @modelattribute(value="listofobjects") formwrapper listofobjects) {     return "redirect:../index.html";  } 

jsp:

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page contenttype="text/html;charset=utf-8" pageencoding="utf-8" %>  <form:form modelattribute="listofobjects" method="post" action="/admin/saveadmin">   <c:foreach var="myobject" items="${listofobjects.list}" varstatus="loop">      <form:checkboxes items="${allcategories}" path="list[${loop.index}].selectedcategories" itemlabel="name"/>    </c:foreach>     <input type="submit" value="savetest"/> </form:form> 

formwrapper:

public class formwrapper { private list<form> list;  public list<form> getlist() {     return list; }  public void setlist(list<form> list) {     this.list = list; }  } 

category:

 public class category{ @id @generatedvalue(strategy=generationtype.identity)  private long categoryid;  private string name;  public string getname() {     return name; }  public void setname(string name) {     this.name = name; }  public long getcategoryid() {     return categoryid; }  public void setcategoryid(long categoryid) {     this.categoryid = categoryid; } @override public boolean equals(object obj) {     if(obj instanceof category){         return getcategoryid().equals(((category)obj).getcategoryid());     } else {         return false;     } } } 

any appreciated. tried change model attribute adnotatnion requestparam , in such case , object null

is because, formwrapper class not have property "selectedcategories". tried removing "selectedcategories" form submitted successfully.

<form:checkboxes items="${allcategories}" path="list[${loop.index}]" itemlabel="name"/> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -