I having a trouble when doing CRUD in Spring+Hibernate MVC project, the IDE return an HTTP Status 400 error. I have checked some link but they are not the solution:
- The request sent by the client was syntactically incorrect.-Spring MVC + JDBC Template
- Spring: The request sent by the client was syntactically incorrect ()
- http://www.coderanch.com/t/643301/Spring/Spring-MVC-request-message-request
Here is the form:form in my jsp page:
<form:form action="quantity.do" method="GET" commandName="quantity">
<form:input type="hidden" path="quantityId" value="1"/>
<form:input type="hidden" path="clothes" value="<%= clothe%>"/>
<div style="height: 35px; width: 20%; float: left;">
Choose color:
</div>
<div style="height: 35px; width: 78%; float: left">
<form:select path="color">
<!--object Color-->
<form:option value="" label=" - choose color - "/>
<form:options items="${colors}" itemLabel="name"/>
</form:select>
</div>
<div style="height: 35px; width: 20%; float: left;">
Choose Size
</div>
<div style="height: 35px; width: 78%; float: left;">
<form:select path="size">
<!--object size-->
<form:option value="" label=" - choose size - "/>
<form:options items="${sizes}" itemLabel="sizeDescription"/>
</form:select>
</div>
<div style="height: 35px; width: 20%; float: left;">
Quantity:
</div>
<div style="height: 35px; width: 78%; float: left;">
<form:input type="number" path="quantityOfClothes"/>
</div>
<div style="width: 100%; height: 25px"></div>
<div style="height: 50px; width: 16%; float: left; margin-left: 50px">
<input type="submit" name="action" value="Add"/>
</div>
<div style="height: 50px; width: 16%; float: left; margin-left: 50px">
<input type="submit" name="action" value="Update"/>
</div>
<div style="height: 50px; width: 16%; float: left; margin-left: 50px">
<input type="submit" name="action" value="Cancel"/>
</div>
</form:form>
This is the controller:
@RequestMapping(value = "/quantity.do", method = RequestMethod.GET)
public String doActions(@ModelAttribute Quantity quantity, @RequestParam String action, Map<String, Object> map) {
switch (action.toLowerCase()) {
case "add":
break;
case "update":
break;
case "cancel":
break;
}
return "quantity";
}
All of my objects are implemented through Serializable, when I use "Add" action, the url will show: "http://localhost:8080/pinky_spring/quantity.do?quantityId=1&clothes=model.Clothes@229db7d5&color=model.Color@6b248b2f&size=model.Size@591a3a57&quantityOfClothes=1000&action=Add" with this error. Please tell me what is the problem in here and how to solve that, I am new in Java Web.
update: here is Quantity class
@Entity
@Table(name = "Quantity", schema = "dbo", catalog = "PinkyDB")
public class Quantity implements java.io.Serializable {
private int quantityId;
private Clothes clothes; //an object
private Color color; //an object
private Size size; //an object
private Integer quantityOfClothes;
private Set<ShoppingCart> shoppingCarts = new HashSet<ShoppingCart>(0);
public Quantity() {
}
public Quantity(int quantityId, Clothes clothes, Color color, Size size) {
this.quantityId = quantityId;
this.clothes = clothes;
this.color = color;
this.size = size;
}
public Quantity(int quantityId, Clothes clothes, Color color, Size size, Integer quantityOfClothes, Set<ShoppingCart> shoppingCarts) {
this.quantityId = quantityId;
this.clothes = clothes;
this.color = color;
this.size = size;
this.quantityOfClothes = quantityOfClothes;
this.shoppingCarts = shoppingCarts;
}
@Id
@Column(name = "QuantityID", unique = true, nullable = false)
public int getQuantityId() {
return this.quantityId;
}
public void setQuantityId(int quantityId) {
this.quantityId = quantityId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ClothID", nullable = false)
public Clothes getClothes() {
return this.clothes;
}
public void setClothes(Clothes clothes) {
this.clothes = clothes;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ColorID", nullable = false)
public Color getColor() {
return this.color;
}
public void setColor(Color color) {
this.color = color;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "SizeID", nullable = false)
public Size getSize() {
return this.size;
}
public void setSize(Size size) {
this.size = size;
}
@Column(name = "QuantityOfClothes")
public Integer getQuantityOfClothes() {
return this.quantityOfClothes;
}
public void setQuantityOfClothes(Integer quantityOfClothes) {
this.quantityOfClothes = quantityOfClothes;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "quantity")
public Set<ShoppingCart> getShoppingCarts() {
return this.shoppingCarts;
}
public void setShoppingCarts(Set<ShoppingCart> shoppingCarts) {
this.shoppingCarts = shoppingCarts;
}}