简体   繁体   中英

HTTP Status 400 - The request sent by the client was syntactically incorrect

There is some problem in it. as it gives Http status 400- The request sent by the client was syntactically incorrect. when i submit. it doesnt reach to the controller. Kindly review and help.

<c:url var="addr" value="/productsPage"/>
 <form:form method="POST" action="${addr}" modelAttribute="productsmodel"  enctype="multipart/form-data">

<form:input type="hidden" path="productId" value="" />
<form:input type="hidden" path="vendorDetails" value="" />
<form:input type="hidden" path="productDetail" value="" />

<tr><td>Product Name:--</td><td><form:input type="text" path="ProductName" value=""/></td></tr>
<tr><td>Product Description:--</td><td><form:input type="text" path="ProductDescription" value="" /></td></tr>
<tr><td>Category:--
</td><td><form:input type="text" path="Category" name="categorylist" list="listcategory" />
                            <datalist id="listcategory">
                            <option value="Add New">
                            <c:forEach items="${all_categories}" var="all_categories">
                            <option value="${all_categories.categoryName}">                         
                            </c:forEach>
                            </datalist>                     

</td></tr>
<tr><td>Quantity/Unit:--</td><td><form:input type="text" path="quantityPerUnit" value="" /></td></tr>
<tr><td>Unit Price:--</td><td><form:input type="text" path="unitPrice" value="" /></td></tr>
<tr><td>Size:--</td><td><form:radiobutton  path="size" value="1"/>L<form:radiobutton  path="size" value="2"/>M<form:radiobutton  path="size" value="3"/>S<form:radiobutton  path="size" value="0"/>NA</td></tr>
<tr><td>Color:--</td><td><form:input type="text" path="color" value=""/></td></tr>
<tr><td>Discount:--</td><td><form:input type="text" path="discount" value=""/></td></tr>
<tr><td>Weight/Unit:--</td><td><form:input type="text" path="weight" value=""/></td></tr>
<tr><td>Units on Order:--</td><td><form:input type="text" path="unitsOnOrder" value=""/></td></tr>
<tr><td>Picture:--</td><td><input type="file" name="pictureLink" size="100" /></td></tr>

<tr><td></td><td><input type="submit" value="Save"/></td></tr>

</form:form>

</table>

Controller

{

@RequestMapping(value={"/productsPage"},method=RequestMethod.POST)  
public String ProductPost(@ModelAttribute("productsmodel") Products products, Model model,@RequestParam("picture") MultipartFile file1){


    System.out.println("In Post Products");

    return "products";
    }

}

Model {

@Entity
@Table(name="Products")
public class Products
{
  @Id
  @GeneratedValue
  @Column(name="ProductId")
    private Integer productId;

  @Column(name="productName")
  private String ProductName;

  @Column(name="productDescription")
  private String ProductDescription;

  @ManyToOne
  @JoinColumn(name="category")
  private Categories category;

  @Column(name="quantityPerUnit")
  private int quantityPerUnit;

  @Column(name="unitPrice")
  private BigDecimal unitPrice;

  @Column(name="size")
  private int size;

  @Column(name="color")
  private String color;

  @Column(name="discount")
  private BigDecimal discount;

  @Column(name="weight")
  private double weight;

  @Column(name="unitsOnOrder")
  private int unitsOnOrder;

  @ManyToOne
  @JoinColumn(name="vendorDetailsId")
  private Vendor vendorDetails;

  @OneToOne
  @JoinColumn(name="ProductExtraDetails")
  private ProductExtraDetails productDetail;

}

Thank you. I figure it out.

Category, productDetail and vendordetails are joined to other table, and have to add their ID's. ie productDetail.productID as path

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM