我有一个Mapsauda包含2个帐户详细信息买方和卖方。我希望通过使用souda entryform的thmelaf和model进行查找和获取帐户来设置这两个细节。由于未能将字符串转换为自定义类帐户,我收到错误消息。如何解决这个问题。。?
帐户pojo
package org.temp.bean.pojo;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.PositiveOrZero;
import org.hibernate.validator.constraints.Length;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class AccountPOJO {
@NotBlank
@NotNull
@Length(min = 2,max=255)
private String name;
@NotNull
@NotBlank
@Length(min = 2,max=255)
private String city;
@PositiveOrZero
@Length(min=0,max = 15)
private Integer gstno;
@Length(min = 0,max = 14)
@PositiveOrZero
private Integer fssai;
}
索达波霍
package org.temp.bean.pojo;
import java.util.Date;
import javax.validation.constraints.Positive;
import javax.validation.constraints.PositiveOrZero;
import org.temp.bean.OptionEnum;
import org.temp.bean.QuantityType;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SaudaPOJO {
@DateTimeFormat(iso = ISO.DATE)
private Date saudaStartDate;
@DateTimeFormat(iso = ISO.DATE)
private Date saudaEndDate;
private AccountPOJO sellerAccount;
private AccountPOJO buyerAccount;
@Positive
private Integer rate;
@Positive
private Integer quantity;
private String tankerNo;
private String refNo;
@PositiveOrZero
private Integer deposit;
private String description;
private OptionEnum options;
private QuantityType type;
}
html代码段
<label for="sellerAccount">Seller Account</label>
<input
list="sellerAccounts" th:field="*{sellerAccount}"
id="sellerAccount" name="sellerAccount"
placeholder="Seller Account name" class="form-control"
th:error-class="has-error">
<datalist id="sellerAccounts" >
<select th:each="account: ${Accounts}">
<option th:text="${account.name}" th:value="${account.name}"></option>
</select>
</datalist>
<div class="form-group"
th:class="${#fields.hasErrors('sellerAccount')} ? 'form-group has-error' : 'form-group'">
<ul th:if="${#fields.hasErrors('sellerAccount')}">
<li th:each="err : ${#fields.errors('sellerAccount')}"
th:text="${err}">
</ul>
</div>
<label for="buyerAccount">Buyer's Account</label> <input
list="buyerAccounts" th:field="*{buyerAccount}" id="buyerAccount"
name="buyerAccount" placeholder="Buyer Account name"
class="form-control" th:error-class="has-error">
<datalist id="buyerAccounts" >
<select th:each="account: ${Accounts}">
<option th:text="${account.name}" th:value="${account.name}"></option>
</select>
</datalist>
<div class="form-group"
th:class="${#fields.hasErrors('buyerAccount')} ? 'form-group has-error' : 'form-group'">
<ul th:if="${#fields.hasErrors('buyerAccount')}">
<li th:each="err : ${#fields.errors('buyerAccount')}"
th:text="${err}">
</ul>
</div>
将页面转换为sauda时。如何通过在数据库中查找并获取关联帐户来获得字符串到类的Map。我用的Spring Boot与百里香叶和Lombok山。下面是相同错误的片段
html错误代码段
控制器
@GetMapping("/sauda/insert")
public String insertSauda(Model model)
{
model.addAttribute(SAUDA,new SaudaPOJO());
List<AccountPOJO> listaccounts= accountService.getAllAccount();
model.addAttribute("Accounts",listaccounts);
return "sauda/insertsauda";
}
暂无答案!
目前还没有任何答案,快来回答吧!