0

Whenever i want to save my entity, it throws this error : Http 400 error, "The request sent by the client was syntactically incorrect."
edit.jsp:

   <f:form action = "update.html" modelAttribute="Dolgozo">
        <input type="hidden" name = "id" value="${d.dolgozoId}">
        <label for="nev">Név: </label>
        <input type="text" name = "nev" value="${d.nev}">
           </br>
        <label for="szulido">Születési idő: </label>
        <input type="date" name = "szulido" value="${d.szulido}">
            </br>
        <label for="anyjaneve">Anyja neve: </label>
        <input type="text" name = "anyjaneve" value="${d.anyjaneve}">
            </br>
        <label for="telefonszam,">Telefonszám: </label>
        <input type="text" name = "telefonszam" value="${d.telefonszam}">
            </br>
        <label for="lakcim">Lakcím: </label>
        <input type="text" name = "lakcim" value="${d.lakcim}">
            </br>
        <input type="submit" value="Módosít">
    </f:form>

Controller:

@Controller
public class DolgozoController {

@RequestMapping(value = "index")
public ModelAndView redirect(){
    ModelAndView MV = new ModelAndView();
    MV.setView("index");
    return MV;
}

@RequestMapping(value = "getAll", method = RequestMethod.GET)
public String getAll(Model m){

    DolgozoModel model = new DolgozoModel();
    m.addAttribute("lst", model.getAll());

    return "data";

}

@RequestMapping(value = "edit", method = RequestMethod.GET)
public String edit(@RequestParam(value = "id") int id, Model m){
    java.math.BigDecimal bd = new  java.math.BigDecimal(String.valueOf(id));
    DolgozoModel model = new DolgozoModel();
    Dolgozo d = new Dolgozo();

    d = model.getDolgozo(bd);
    m.addAttribute("d", d );
    return "edit";

} 

@RequestMapping(value = "update", method = RequestMethod.POST)
public String update(@ModelAttribute(value = "Dolgozo")Dolgozo d){

    DolgozoModel model = new DolgozoModel();
    Dolgozo dolg = new Dolgozo();
    dolg = model.getDolgozo(dolg.getDolgozoId());

    dolg.setNev(d.getNev());
    dolg.setAnyjaneve(d.getAnyjaneve());
   //dolg.setSzulido(d.getSzulido());
    dolg.setLakcim(d.getLakcim());
    dolg.setTelefonszam(d.getTelefonszam());

    model.edit(dolg);

return"redirect:getAll.html";
}
}

I'am using 'Date' attribute on my entity, maybe this is the problem?

TeglaTheOne
  • 53
  • 2
  • 9
  • Show the Model and a network trace from F12. Most likely you will have to tell Jackson how to deserialize the date – Marged Jan 07 '16 at 17:21
  • it returns the following dateformat : 2016.01.06 – TeglaTheOne Jan 07 '16 at 17:49
  • for a quick test: remove the date. If everything works fine then you need to tell Jackson how to deserialize the date you have (normally it expects a timestamp). See http://stackoverflow.com/questions/5591967/how-to-deserialize-js-date-using-jackson. And you should run your spring app with debug level, then you should see what it is unable to process – Marged Jan 07 '16 at 20:18
  • Turn your Spring logs to DEBUG and see what they say. – Sotirios Delimanolis Jan 07 '16 at 20:42
  • in the update method, the date attribb is commented (szulido is date) – TeglaTheOne Jan 07 '16 at 20:51

1 Answers1

0

Your action is wrong write it like this:

 <f:form action = "update" modelAttribute="Dolgozo" method="post">

And the path should like below:

 @RequestMapping(value = "/update", method = RequestMethod.POST)
Abdelhak
  • 8,299
  • 4
  • 22
  • 36
  • then it throws this error: HTTP Status 404 - /crudSpringMvc/update type Status report message /crudSpringMvc/update description The requested resource is not available. – TeglaTheOne Jan 07 '16 at 17:27
  • post all your controller calss @TeglaTheOne – Abdelhak Jan 07 '16 at 17:31
  • @TeglaTheOne take a lookat answer – Abdelhak Jan 07 '16 at 17:37
  • Try to add this in your action="${pageContext.request.contextPath}/update" @TeglaTheOne – Abdelhak Jan 07 '16 at 17:56
  • Why do you think there's anything wrong with their `action`? Spring handles suffix matches just fine with `RequestMappingHandlerMapping#setUseSuffixPatternMatch` set to `true`. Your answer also doesn't explain the 400 status code they've received or how to resolve it. – Sotirios Delimanolis Jan 07 '16 at 20:42