java - The request sent by the client was syntactically incorrect. HTTP Status 400 - -
i have method signature in @controller
@requestmapping("/savecandidate") public string savecandidate(model model, @modelattribute("candidatefromrequest") candidate candidatefromrequest, @modelattribute("skillsidlist") set<skill> skills, @modelattribute("vacanciesforcandidate") set<vacancy> vacanciesforcandidate)
and form:
<form action="savecandidate" id="formid" method="post"> .... <input type="submit" value="save changes"/> </form>
in debug see, @modelattribute entities put on request.
why result see
the request sent client syntactically incorrect. http status 400 -
in browser
code:
@modelattribute(value = "candidatefromrequest") public candidate loadcandidatebyid(@requestparam(required = false) integer id) { if (id!= null) return candidateservice.findbyid(id); return null; } @modelattribute(value = "skillsidlist") public set<skill> getskilllistbyid(@requestparam(required = false) list<integer> skills,@modelattribute("skills")list<skill> allskills ) { if (skills== null) return null; set<skill> returnlist = new hashset<skill>(); for(integer skillid:skills){ for(skill skill:allskills){ if(skillid.equals(skill.getid())){ returnlist.add(skill); break; } } } return returnlist; } @modelattribute(value = "vacanciesforcandidate") public set<vacancy> vacanciesforcandidate(@requestparam(required = false) list<integer> vacancies,@modelattribute("vacancies")list<vacancy> allvacancies ) { if (vacancies== null) return null; set<vacancy> returnlist = new hashset<vacancy>(); for(integer vacancyid:vacancies){ for(vacancy vacancy:allvacancies){ if(vacancyid.equals(vacancy.getid())){ returnlist.add(vacancy); break; } } } return returnlist; }
in debug saw, methods, writes above return valid values.
i replace mehod , saw browser request:
http://localhost:8080/ui/savecandidate?name=evgeniy&surname=rogachev&phone=02&resumeurl=http%3a%2f%2fgoogle.com&id=1013&skills=2&skills=3&skills=4&skills=5&skills=6&skills=7&skills=8&vacancies=6&vacancies=12&vacancies=14
Comments
Post a Comment