我尝试了不同的方式将其用作List<String>
,但它没有用。
<c:forEach items="${sales_contract.Positions}" var="position"
varStatus="status">
<select name="position[0].Position">
<c:forEach items="${positions_list}" var="pos">
<option value="${pos}"><c:out value="${pos.Position_Name}"></c:out></option>
</c:forEach>
</select>
</c:forEach>
&#34;位置&#34; in forEach items是modelAttribute sales_contract下的列表对象。
为了进行测试,我只是尝试在上面的列表中为第0个对象填充该对象。
在inner forEach中,positions_list是List<Positions>
类型的Object。
我也使用了spring form标签,
<c:forEach items="${sales_contract.Positions}" var="position"
varStatus="status">
<form:select path="sales_contract.Positions[${status.index}].Position"
items="${positions_list}">
</form:select>
</c:forEach>
它也没有用。它不会产生任何错误,但表单上没有任何内容。
模型结构如下,
SalesContract
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long external_id;
private long ID;
private String Sales_Rep;
private long Sales_Contract_Number;
private Date Order_Date;
private String Status;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name="account_id")
private Account Account;
private String Contact;
private String shipping_add_identifier;
private String shipping_address_name;
private String shipping_c_o;
private String Shipping_Street;
private String Shipping_City;
private String Shipping_State;
private String Shipping_Zip_Code;
private String Shipping_Country;
@Column(columnDefinition = "TEXT")
private String Carrier_Instructions;
@Column(columnDefinition = "TEXT")
private String Warehouse_Instructions;
private String Terms;
private BigDecimal Hold_for_Funds;
private String Credit_Card_Fee;
private String Carrier;
private String Shipping_Cost_Payment;
private boolean Expedite;
private BigDecimal Total_Amount_usd;
private BigDecimal Total_Amount_RMB;
private BigDecimal Pre_Payments_Requested;
private BigDecimal Payments_Made;
@Column(columnDefinition = "TEXT")
private String Customer_Comment;
@OneToMany
@JoinColumn(name="ID")
private List<SalesOrderPosition> Positions;
public long getSales_contract_id() {
return external_id;
}
public long getExternal_id() {
return external_id;
}
public void setExternal_id(long external_id) {
this.external_id = external_id;
}
public long getID() {
return ID;
}
public void setID(long iD) {
ID = iD;
}
public String getShipping_add_identifier() {
return shipping_add_identifier;
}
public void setShipping_add_identifier(String shipping_add_identifier) {
this.shipping_add_identifier = shipping_add_identifier;
}
public String getShipping_address_name() {
return shipping_address_name;
}
public void setShipping_address_name(String shipping_address_name) {
this.shipping_address_name = shipping_address_name;
}
public String getShipping_c_o() {
return shipping_c_o;
}
public void setShipping_c_o(String shipping_c_o) {
this.shipping_c_o = shipping_c_o;
}
public void setSales_contract_id(long sales_contract_id) {
this.external_id = sales_contract_id;
}
public String getSales_Rep() {
return Sales_Rep;
}
public void setSales_Rep(String sales_Rep) {
Sales_Rep = sales_Rep;
}
public long getSales_Contract_Number() {
return Sales_Contract_Number;
}
public void setSales_Contract_Number(long sales_Contract_Number) {
Sales_Contract_Number = sales_Contract_Number;
}
public Date getOrder_Date() {
return Order_Date;
}
public void setOrder_Date(Date order_Date) {
Order_Date = order_Date;
}
public String getStatus() {
return Status;
}
public void setStatus(String status) {
Status = status;
}
public Account getAccount() {
return Account;
}
public void setAccount(Account account) {
Account = account;
}
public String getContact() {
return Contact;
}
public void setContact(String contact) {
Contact = contact;
}
public String getShipping_Street() {
return Shipping_Street;
}
public void setShipping_Street(String shipping_Street) {
Shipping_Street = shipping_Street;
}
public String getShipping_City() {
return Shipping_City;
}
public void setShipping_City(String shipping_City) {
Shipping_City = shipping_City;
}
public String getShipping_State() {
return Shipping_State;
}
public void setShipping_State(String shipping_State) {
Shipping_State = shipping_State;
}
public String getShipping_Zip_Code() {
return Shipping_Zip_Code;
}
public void setShipping_Zip_Code(String shipping_Zip_Code) {
Shipping_Zip_Code = shipping_Zip_Code;
}
public String getShipping_Country() {
return Shipping_Country;
}
public void setShipping_Country(String shipping_Country) {
Shipping_Country = shipping_Country;
}
public String getCarrier_Instructions() {
return Carrier_Instructions;
}
public void setCarrier_Instructions(String carrier_Instructions) {
Carrier_Instructions = carrier_Instructions;
}
public String getWarehouse_Instructions() {
return Warehouse_Instructions;
}
public void setWarehouse_Instructions(String warehouse_Instructions) {
Warehouse_Instructions = warehouse_Instructions;
}
public String getTerms() {
return Terms;
}
public void setTerms(String terms) {
Terms = terms;
}
public BigDecimal getHold_for_Funds() {
return Hold_for_Funds;
}
public void setHold_for_Funds(BigDecimal hold_for_Funds) {
Hold_for_Funds = hold_for_Funds;
}
public String getCredit_Card_Fee() {
return Credit_Card_Fee;
}
public void setCredit_Card_Fee(String credit_Card_Fee) {
Credit_Card_Fee = credit_Card_Fee;
}
public String getCarrier() {
return Carrier;
}
public void setCarrier(String carrier) {
Carrier = carrier;
}
public String getShipping_Cost_Payment() {
return Shipping_Cost_Payment;
}
public void setShipping_Cost_Payment(String shipping_Cost_Payment) {
Shipping_Cost_Payment = shipping_Cost_Payment;
}
public boolean isExpedite() {
return Expedite;
}
public void setExpedite(boolean expedite) {
Expedite = expedite;
}
public BigDecimal getTotal_Amount_usd() {
return Total_Amount_usd;
}
public void setTotal_Amount_usd(BigDecimal total_Amount_usd) {
Total_Amount_usd = total_Amount_usd;
}
public BigDecimal getTotal_Amount_RMB() {
return Total_Amount_RMB;
}
public void setTotal_Amount_RMB(BigDecimal total_Amount_RMB) {
Total_Amount_RMB = total_Amount_RMB;
}
public BigDecimal getPre_Payments_Requested() {
return Pre_Payments_Requested;
}
public void setPre_Payments_Requested(BigDecimal pre_Payments_Requested) {
Pre_Payments_Requested = pre_Payments_Requested;
}
public BigDecimal getPayments_Made() {
return Payments_Made;
}
public void setPayments_Made(BigDecimal payments_Made) {
Payments_Made = payments_Made;
}
public String getCustomer_Comment() {
return Customer_Comment;
}
public void setCustomer_Comment(String customer_Comment) {
Customer_Comment = customer_Comment;
}
public List<SalesOrderPosition> getPositions() {
return Positions;
}
public void setPositions(List<SalesOrderPosition> positions) {
Positions = positions;
}
位置:
@Id
private long ID;
private String Product;
private String Lot;
private String Position_Name;
private String Location;
private String Final_Warehouse;
private boolean Warehouse_Open;
private String ETA_final_Warehouse;
private String Spot_String_current_Warehouse;
private boolean Contract_Price_Fixed;
private String Landed_Price_per_lb;
private String Landed_Differential;
private String Price_Adjustment_ct_lb;
private String Work_Order_Costs;
private String Price_Per_lb;
private String Differential;
private boolean Do_Not_Sell;
private boolean Do_Not_Ship;
private String UoM_Type;
private String Weight_per_Unit_in_kgs;
private String Weight_per_Unit_in_lbs;
private Integer Original_Quantity;
private Integer Quantity_Available_For_Sale;
private Integer Quantity_Sold;
private Integer Quantity_Processed;
private Integer Quantity_on_Work_Orders;
private Integer Quantity_Physically_Available;
private String Landed_Score;
public long getID() {
return ID;
}
public void setID(long iD) {
ID = iD;
}
public String getProduct() {
return Product;
}
public void setProduct(String product) {
Product = product;
}
public String getLot() {
return Lot;
}
public void setLot(String lot) {
Lot = lot;
}
public String getPosition_Name() {
return Position_Name;
}
public void setPosition_Name(String position_Name) {
Position_Name = position_Name;
}
public String getLocation() {
return Location;
}
public void setLocation(String location) {
Location = location;
}
public String getFinal_Warehouse() {
return Final_Warehouse;
}
public void setFinal_Warehouse(String final_Warehouse) {
Final_Warehouse = final_Warehouse;
}
public boolean isWarehouse_Open() {
return Warehouse_Open;
}
public void setWarehouse_Open(boolean warehouse_Open) {
Warehouse_Open = warehouse_Open;
}
public String getETA_final_Warehouse() {
return ETA_final_Warehouse;
}
public void setETA_final_Warehouse(String eTA_final_Warehouse) {
ETA_final_Warehouse = eTA_final_Warehouse;
}
public String getSpot_String_current_Warehouse() {
return Spot_String_current_Warehouse;
}
public void setSpot_String_current_Warehouse(String spot_String_current_Warehouse) {
Spot_String_current_Warehouse = spot_String_current_Warehouse;
}
public boolean isContract_Price_Fixed() {
return Contract_Price_Fixed;
}
public void setContract_Price_Fixed(boolean contract_Price_Fixed) {
Contract_Price_Fixed = contract_Price_Fixed;
}
public String getLanded_Price_per_lb() {
return Landed_Price_per_lb;
}
public void setLanded_Price_per_lb(String landed_Price_per_lb) {
Landed_Price_per_lb = landed_Price_per_lb;
}
public String getLanded_Differential() {
return Landed_Differential;
}
public void setLanded_Differential(String landed_Differential) {
Landed_Differential = landed_Differential;
}
public String getPrice_Adjustment_ct_lb() {
return Price_Adjustment_ct_lb;
}
public void setPrice_Adjustment_ct_lb(String price_Adjustment_ct_lb) {
Price_Adjustment_ct_lb = price_Adjustment_ct_lb;
}
public String getWork_Order_Costs() {
return Work_Order_Costs;
}
public void setWork_Order_Costs(String work_Order_Costs) {
Work_Order_Costs = work_Order_Costs;
}
public String getPrice_Per_lb() {
return Price_Per_lb;
}
public void setPrice_Per_lb(String price_Per_lb) {
Price_Per_lb = price_Per_lb;
}
public String getDifferential() {
return Differential;
}
public void setDifferential(String differential) {
Differential = differential;
}
public boolean isDo_Not_Sell() {
return Do_Not_Sell;
}
public void setDo_Not_Sell(boolean do_Not_Sell) {
Do_Not_Sell = do_Not_Sell;
}
public boolean isDo_Not_Ship() {
return Do_Not_Ship;
}
public void setDo_Not_Ship(boolean do_Not_Ship) {
Do_Not_Ship = do_Not_Ship;
}
public String getUoM_Type() {
return UoM_Type;
}
public void setUoM_Type(String uoM_Type) {
UoM_Type = uoM_Type;
}
public String getWeight_per_Unit_in_kgs() {
return Weight_per_Unit_in_kgs;
}
public void setWeight_per_Unit_in_kgs(String weight_per_Unit_in_kgs) {
Weight_per_Unit_in_kgs = weight_per_Unit_in_kgs;
}
public String getWeight_per_Unit_in_lbs() {
return Weight_per_Unit_in_lbs;
}
public void setWeight_per_Unit_in_lbs(String weight_per_Unit_in_lbs) {
Weight_per_Unit_in_lbs = weight_per_Unit_in_lbs;
}
public Integer getOriginal_Quantity() {
return Original_Quantity;
}
public void setOriginal_Quantity(Integer original_Quantity) {
Original_Quantity = original_Quantity;
}
public Integer getQuantity_Available_For_Sale() {
return Quantity_Available_For_Sale;
}
public void setQuantity_Available_For_Sale(Integer quantity_Available_For_Sale) {
Quantity_Available_For_Sale = quantity_Available_For_Sale;
}
public Integer getQuantity_Sold() {
return Quantity_Sold;
}
public void setQuantity_Sold(Integer quantity_Sold) {
Quantity_Sold = quantity_Sold;
}
public Integer getQuantity_Processed() {
return Quantity_Processed;
}
public void setQuantity_Processed(Integer quantity_Processed) {
Quantity_Processed = quantity_Processed;
}
public Integer getQuantity_on_Work_Orders() {
return Quantity_on_Work_Orders;
}
public void setQuantity_on_Work_Orders(Integer quantity_on_Work_Orders) {
Quantity_on_Work_Orders = quantity_on_Work_Orders;
}
public Integer getQuantity_Physically_Available() {
return Quantity_Physically_Available;
}
public void setQuantity_Physically_Available(Integer quantity_Physically_Available) {
Quantity_Physically_Available = quantity_Physically_Available;
}
public String getLanded_Score() {
return Landed_Score;
}
public void setLanded_Score(String landed_Score) {
Landed_Score = landed_Score;
}
SalesOrderPosition:
@Id
private long ID;
private String Position;
private String Service;
@Column(columnDefinition = "TEXT")
private String Add_Description;
private Integer Qty_Ordered;
private BigDecimal Weight_per_Unit_kgs;
private BigDecimal Weight_per_Unit_lbs;
private String Price_Fixed;
private BigDecimal Price_kg;
private BigDecimal Price_lb;
private BigDecimal Market_Price_kg;
private BigDecimal Market_Price_lb;
private BigDecimal Differential_ct_lb;
private BigDecimal Margin_ct_lb;
private String CC_Fee_Rate;
private BigDecimal CC_Fee;
private BigDecimal Carry_Rate_per_Month;
private BigDecimal Carry_Cost;
private BigDecimal Final_Price_kg;
private BigDecimal Final_Price_RMB_kg;
private BigDecimal Amount_usd;
private BigDecimal Amount_RMB;
private String Terms;
private Date Custom_Due_Date;
private String Incoterms;
private String Weight_Terms;
private String Shipping_Address;
private boolean Ship_to_Customer;
private Date Shipping_Date;
private String Ship_ASAP;
private String Ship_Month;
private Integer Qty_on_Ship_Order;
private Integer Qty_Shipped;
private String SAS_Code;
private String Customer_PO;
private String Comment;
private String Status;
public long getId() {
return ID;
}
public void setId(long id) {
this.ID = id;
}
public String getPosition() {
return Position;
}
public void setPosition(String position) {
Position = position;
}
public String getService() {
return Service;
}
public void setService(String service) {
Service = service;
}
public String getAdd_Description() {
return Add_Description;
}
public void setAdd_Description(String add_Description) {
Add_Description = add_Description;
}
public Integer getQty_Ordered() {
return Qty_Ordered;
}
public void setQty_Ordered(Integer qty_Ordered) {
Qty_Ordered = qty_Ordered;
}
public BigDecimal getWeight_per_Unit_kgs() {
return Weight_per_Unit_kgs;
}
public void setWeight_per_Unit_kgs(BigDecimal weight_per_Unit_kgs) {
Weight_per_Unit_kgs = weight_per_Unit_kgs;
}
public BigDecimal getWeight_per_Unit_lbs() {
return Weight_per_Unit_lbs;
}
public void setWeight_per_Unit_lbs(BigDecimal weight_per_Unit_lbs) {
Weight_per_Unit_lbs = weight_per_Unit_lbs;
}
public String getPrice_Fixed() {
return Price_Fixed;
}
public void setPrice_Fixed(String price_Fixed) {
Price_Fixed = price_Fixed;
}
public BigDecimal getPrice_kg() {
return Price_kg;
}
public void setPrice_kg(BigDecimal price_kg) {
Price_kg = price_kg;
}
public BigDecimal getPrice_lb() {
return Price_lb;
}
public void setPrice_lb(BigDecimal price_lb) {
Price_lb = price_lb;
}
public BigDecimal getMarket_Price_kg() {
return Market_Price_kg;
}
public void setMarket_Price_kg(BigDecimal market_Price_kg) {
Market_Price_kg = market_Price_kg;
}
public BigDecimal getMarket_Price_lb() {
return Market_Price_lb;
}
public void setMarket_Price_lb(BigDecimal market_Price_lb) {
Market_Price_lb = market_Price_lb;
}
public BigDecimal getDifferential_ct_lb() {
return Differential_ct_lb;
}
public void setDifferential_ct_lb(BigDecimal differential_ct_lb) {
Differential_ct_lb = differential_ct_lb;
}
public BigDecimal getMargin_ct_lb() {
return Margin_ct_lb;
}
public void setMargin_ct_lb(BigDecimal margin_ct_lb) {
Margin_ct_lb = margin_ct_lb;
}
public String getCC_Fee_Rate() {
return CC_Fee_Rate;
}
public void setCC_Fee_Rate(String cC_Fee_Rate) {
CC_Fee_Rate = cC_Fee_Rate;
}
public BigDecimal getCC_Fee() {
return CC_Fee;
}
public void setCC_Fee(BigDecimal cC_Fee) {
CC_Fee = cC_Fee;
}
public BigDecimal getCarry_Rate_per_Month() {
return Carry_Rate_per_Month;
}
public void setCarry_Rate_per_Month(BigDecimal carry_Rate_per_Month) {
Carry_Rate_per_Month = carry_Rate_per_Month;
}
public BigDecimal getCarry_Cost() {
return Carry_Cost;
}
public void setCarry_Cost(BigDecimal carry_Cost) {
Carry_Cost = carry_Cost;
}
public BigDecimal getFinal_Price_kg() {
return Final_Price_kg;
}
public void setFinal_Price_kg(BigDecimal final_Price_kg) {
Final_Price_kg = final_Price_kg;
}
public BigDecimal getFinal_Price_RMB_kg() {
return Final_Price_RMB_kg;
}
public void setFinal_Price_RMB_kg(BigDecimal final_Price_RMB_kg) {
Final_Price_RMB_kg = final_Price_RMB_kg;
}
public BigDecimal getAmount_usd() {
return Amount_usd;
}
public void setAmount_usd(BigDecimal amount_usd) {
Amount_usd = amount_usd;
}
public BigDecimal getAmount_RMB() {
return Amount_RMB;
}
public void setAmount_RMB(BigDecimal amount_RMB) {
Amount_RMB = amount_RMB;
}
public String getTerms() {
return Terms;
}
public void setTerms(String terms) {
Terms = terms;
}
public Date getCustom_Due_Date() {
return Custom_Due_Date;
}
public void setCustom_Due_Date(Date custom_Due_Date) {
Custom_Due_Date = custom_Due_Date;
}
public String getIncoterms() {
return Incoterms;
}
public void setIncoterms(String incoterms) {
Incoterms = incoterms;
}
public String getWeight_Terms() {
return Weight_Terms;
}
public void setWeight_Terms(String weight_Terms) {
Weight_Terms = weight_Terms;
}
public String getShipping_Address() {
return Shipping_Address;
}
public void setShipping_Address(String shipping_Address) {
Shipping_Address = shipping_Address;
}
public boolean isShip_to_Customer() {
return Ship_to_Customer;
}
public void setShip_to_Customer(boolean ship_to_Customer) {
Ship_to_Customer = ship_to_Customer;
}
public Date getShipping_Date() {
return Shipping_Date;
}
public void setShipping_Date(Date shipping_Date) {
Shipping_Date = shipping_Date;
}
public String getShip_ASAP() {
return Ship_ASAP;
}
public void setShip_ASAP(String ship_ASAP) {
Ship_ASAP = ship_ASAP;
}
public String getShip_Month() {
return Ship_Month;
}
public void setShip_Month(String ship_Month) {
Ship_Month = ship_Month;
}
public Integer getQty_on_Ship_Order() {
return Qty_on_Ship_Order;
}
public void setQty_on_Ship_Order(Integer qty_on_Ship_Order) {
Qty_on_Ship_Order = qty_on_Ship_Order;
}
public Integer getQty_Shipped() {
return Qty_Shipped;
}
public void setQty_Shipped(Integer qty_Shipped) {
Qty_Shipped = qty_Shipped;
}
public String getSAS_Code() {
return SAS_Code;
}
public void setSAS_Code(String sAS_Code) {
SAS_Code = sAS_Code;
}
public String getCustomer_PO() {
return Customer_PO;
}
public void setCustomer_PO(String customer_PO) {
Customer_PO = customer_PO;
}
public String getComment() {
return Comment;
}
public void setComment(String comment) {
Comment = comment;
}
public String getStatus() {
return Status;
}
public void setStatus(String status) {
Status = status;
}
最后,映射是这样的,SalesContract有一个SalesOrderPosition类型的列表对象,它有一个名为String类型的属性。哪个必须从Position类中编写,该类用作jsp中的下拉列表,名称为positions_list。我只想使用Position类的Position_Name字段在SalesOrderPosition中填写多行的位置,因此我尝试使用<c:forEach>
标记。
感谢。