gpt4 book ai didi

java - 对象 ='auctionItem' 的验证失败

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:50:49 27 4
gpt4 key购买 nike

当尝试提交我的表单以创建新拍卖时,浏览器中出现此错误:

Whitelabel Error Page:

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Mar 30 21:00:15 BST 2017 There was an unexpected error (type=Bad Request, status=400) Validation failed for object='auctionItem'. Error count: 2

我似乎无法在我的日志中找到任何特定错误,因此我无法找到错误页面上显示的两个验证错误。在这一点上我很迷茫。希望有人能帮助我,这让我目前无法取得进步。

JSP 文件:

<body id="product" class="product">
<header>
<%@include file="../jsp/Header.jsp" %>
</header>
<div>
<div class="container">
<div class ="row">
<div class="center_column">
<h2 style=" ">Create New Listing</h2>
<mvc:form class="form-inline" action="sell" method="post" modelAttribute="newAuction" id="addNewAuc">
<div class="form-inline" cssClass="TitleBlock">
<label class="control-label">Title</label>
<div>
<mvc:input path="aTitle" type="text" required="true" cssClass="Title" class="form-control" placeholder="Please enter title of item" maxlength="55" minlength="40"/>
</div>
</div>

<div class="form-group ">
<label class="control-label">Item Condition</label>
<div style="padding-top: 4px;">
<mvc:select path="aCondition">
<mvc:option value="New">New</mvc:option>
<mvc:option value="Used">Used</mvc:option>
</mvc:select>
</div>
</div>
<div class="form-group ">
<label class="control-label" style = "padding-left: 15px;">Can the item be returned?</label>
<div style="padding-top: 4px; padding-left: 15px;">
<mvc:select path="aReturns">
<mvc:option value="You can return">Yes</mvc:option>
<mvc:option value="Seller does not offer returns">No</mvc:option>
</mvc:select>
</div>
</div>
<div class="form-inline">
<label class="control-label">Description</label>
<div>
<mvc:textarea path="aDescription" required="true" cssClass="Desc" class="form-control" rows="3" name="Description" placeholder="Item description"/>
</div>
</div>

<div class="form-inline">
<label class="control-label">Category</label>
<div style="padding-top: 4px;">
<mvc:select path="categories">
<mvc:option value="category1">Electronics</mvc:option>
<mvc:option value="category2">Fashion</mvc:option>
<mvc:option value="category3">Home & Gardens</mvc:option>
<mvc:option value="category4">Toys & Games</mvc:option>
<mvc:option value="category5">Sports & Leisure</mvc:option>
</mvc:select>
</div>
</div>
<div class="form-inline">
<label class="control-label ">Minimum Price</label>
<div style="padding-top: 4px;">
<mvc:input path="aBottomPrice" type="number" step="any" required="true" class="form-control" placeholder="?"/>
</div>
</div>
<div class="form-inline">
<label class="control-label ">Starting Price</label>
<div style="padding-top: 4px;">
<mvc:input path="aTopPrice" type="number" step="any" required="true" class="form-control" placeholder="?"/>
</div>
</div>
<div class="form-inline">
<label class="control-label">End of listing</label>
<div style="padding-top: 4px;">
<mvc:input path="aEnd" type="text" id="datetimepicker" required="true" class="form-control" placeholder="YYYY-MM-DD"/>
</div>
</div>

</mvc:form>
<div class="form-inline">
<div style="padding-top: 10px;">
<button type="submit" name="submit" class="btn btn-success" form="addNewAuc">Next</button>
</div>
</div>
</div>
</div>
</div>
</div>
</body>

AuctionItem 类

@Entity
@Table(name = "auction_items")
public class AuctionItem {


@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idauction;

@Column(name = "auctionTitle")
private String aTitle;

@Column(name = "auctionDescription")
private String aDescription;

@Column(name = "auctionStatus")
private String aStatus;

@Column(name = "auctionStart")
private Date aStart;

@Column(name = "auctionEnd")
private Date aEnd;

private String endTimeAsString;

@Column(name = "auctionCondition")
private String aCondition;

@Column(name = "auctionTopPrice")
private double aTopPrice;

@Column(name = "auctionBottomPrice")
private double aBottomPrice;

private long auctionDuration;

private String aReturns;

@ManyToOne
@JoinColumn(name = "owner")
private User owner;

@ManyToOne
@JoinColumn(name = "cId")
private Category categories;




public long getAuctionDuration() {
return auctionDuration;
}

public void setAuctionDuration(long auctionDuration) {
this.auctionDuration = auctionDuration;
}

public int getaID() {
return idauction;
}

public void setaID(int idauction) {
this.idauction = idauction;
}

public String getaTitle() {
return aTitle;
}

public void setaTitle(String aTitle) {
this.aTitle = aTitle;
}

public String getaDescription() {
return aDescription;
}

public void setaDescription(String aDescription) {
this.aDescription = aDescription;
}

public String getaStatus() {
return aStatus;
}

public void setaStatus(String aStatus) {
this.aStatus = aStatus;
}

public Date getaStart() {
return aStart;
}

public void setaStart(Date aStart) {
this.aStart = aStart;
}

public Date getaEnd() {
return aEnd;
}

public void setaEnd(Date aEnd) {
this.aEnd = aEnd;
}

public String getaCondition() {
return aCondition;
}

public void setaCondition(String aCondition) {
this.aCondition = aCondition;
}

public double getaTopPrice() {
return aTopPrice;
}

public void setaTopPrice(double aTopPrice) {
this.aTopPrice = aTopPrice;
}

public double getaBottomPrice() {
return aBottomPrice;
}

public void setaBottomPrice(double aBottomPrice) {
this.aBottomPrice = aBottomPrice;
}

public User getOwner() {
return owner;
}

public void setOwner(User owner) {
this.owner = owner;
}

public String getaReturns() {
return aReturns;
}

public void setaReturns(String aReturns) {
this.aReturns = aReturns;
}

public Category getCategories() {
return categories;
}

public void setCategories(Category categories) {
this.categories = categories;
}

public String getEndTimeAsString() {
return endTimeAsString;
}

public void setEndTimeAsString(String EndTimeAsString) {
this.endTimeAsString = EndTimeAsString;
}

}

最佳答案

也许你错过了 Controller 中的“BindingResult ”。示例:

import org.springframework.validation.BindingResult; 

@RequestMapping(value = "/registration", method = RequestMethod.POST)
public String registration(
@ModelAttribute("userlogin") @Valid LoginProfile userlogin,
BindingResult userloginResult)

关于java - 对象 ='auctionItem' 的验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43128591/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com