HTTP Status 400 – Bad Request

前端 未结 2 1633
孤街浪徒
孤街浪徒 2020-12-22 01:21

Hi i am trying to select category while adding new category.Category details get from DB and I am trying to fetch it\'s PK to product command by using <

相关标签:
2条回答
  • 2020-12-22 01:42

    This is an old question but In case anyone else experiences the same issue then look how I solved it. The problem has nothing to do with the post method that was provide. It is thrown by the next page that you are redirecting to ("redirect:/allProduct"). Your ORM could not successfully map the database result to individual objects, this could be caused by not specifying a primary key or having keys that evaluate to null. So visit your database and fix it, make sure you have everything correct in the end.

    0 讨论(0)
  • 2020-12-22 02:02

    This error has nothing to do with <form:select> tag Still There are few things missing in your code which is resulting this error.

    1. In JSP you are trying to upload file along with form data so you need to have multipartResolver bean defined in spring context from common-fileupload.jar MultipartResolver Spring
    2. Controller method should be changed like this

    @RequestMapping(value="/productlist/addproduct" , method= RequestMethod.POST,consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
    public ModelAndView addProdt(@ModelAttribute("prdt") Product p,BindingResult bindingResult)
    
    0 讨论(0)
提交回复
热议问题