Struts2 ModelDriven Set Collection
Struts2中使用ModelDriven Set<OrderDetail> 无法赋值
Order类中包含Set<OrderDetail>
@OneToMany(targetEntity=OrderDetail.class,mappedBy="order",fetch=FetchType.EAGER)
// @Element(value = OrderDetail.class)
// @Key(value = Integer.class)
// @KeyProperty(value = "id")
// @CreateIfNull(value = true)
private Set<OrderDetail> orderDetails=new HashSet<OrderDetail>();
Action中
public class OrderAction implements ModelDriven<Order>{
private static final long serialVersionUID = 1L;
private OrderService orderService;
public void setOrderService(OrderService orderService) {
this.orderService = orderService;
}
@ShowValue(value="产生订单",page="付款页面")
public String makeOrder(){
System.out.println(model);
System.out.println(model.getOrderDetails());
return "makeOrder";
}
JSP中写OrderDetail
<form action="order_front_makeOrder" method="post">
orderDetails[0].personName:<input type="text" name="orderDetails[0].personName" value="大黄"/>
orderDetails[0].personType:<input type="text" name="orderDetails[0].personType" value="ELDER"/>
orderDetails[0].personNo:<input type="text" name="orderDetails[0].personNo" value="13499756425"/>
orderDetails[0].personNoType:<input type="text" name="orderDetails[0].personNoType" value="IDCARD"/>
orderDetails[1].personName:<input type="text" name="orderDetails[1].personName" value="小耿"/>
orderDetails[1].personType:<input type="text" name="orderDetails[1].personType" value="ELDER"/>
orderDetails[1].personNo:<input type="text" name="orderDetails[1].personNo" value="13499436425"/>
orderDetails[1].personNoType:<input type="text" name="orderDetails[1].personNoType" value="IDCARD"/>
orderDetails[2].personName:<input type="text" name="orderDetails[2].personName" value="小陈"/>
orderDetails[2].personType:<input type="text" name="orderDetails[2].personType" value="ELDER"/>
orderDetails[2].personNo:<input type="text" name="orderDetails[2].personNo" value="13493244326425"/>
orderDetails[2].personNoType:<input type="text" name="orderDetails[2].personNoType" value="IDCARD"/>
<input type="submit"/>
错误:应该算异常,在Action中取不到OrderDetail[].
-2016-08-08 16:26:20,893 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[0].personName' on 'class Action.OrderAction: Error setting expression 'orderDetails[0].personName' with value ['大黄', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160417ms]
-2016-08-08 16:26:20,895 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[0].personNo' on 'class Action.OrderAction: Error setting expression 'orderDetails[0].personNo' with value ['13499756425', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160419ms]
-2016-08-08 16:26:20,897 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[0].personNoType' on 'class Action.OrderAction: Error setting expression 'orderDetails[0].personNoType' with value ['IDCARD', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160421ms]
-2016-08-08 16:26:20,899 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[0].personType' on 'class Action.OrderAction: Error setting expression 'orderDetails[0].personType' with value ['ELDER', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160423ms]
-2016-08-08 16:26:20,901 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[1].personName' on 'class Action.OrderAction: Error setting expression 'orderDetails[1].personName' with value ['小耿', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160425ms]
-2016-08-08 16:26:20,903 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[1].personNo' on 'class Action.OrderAction: Error setting expression 'orderDetails[1].personNo' with value ['13499436425', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160427ms]
-2016-08-08 16:26:20,905 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[1].personNoType' on 'class Action.OrderAction: Error setting expression 'orderDetails[1].personNoType' with value ['IDCARD', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160429ms]
-2016-08-08 16:26:20,906 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[1].personType' on 'class Action.OrderAction: Error setting expression 'orderDetails[1].personType' with value ['ELDER', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160430ms]
-2016-08-08 16:26:20,907 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[2].personName' on 'class Action.OrderAction: Error setting expression 'orderDetails[2].personName' with value ['小陈', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160431ms]
-2016-08-08 16:26:20,909 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[2].personNo' on 'class Action.OrderAction: Error setting expression 'orderDetails[2].personNo' with value ['13493244326425', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160433ms]
-2016-08-08 16:26:20,910 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[2].personNoType' on 'class Action.OrderAction: Error setting expression 'orderDetails[2].personNoType' with value ['IDCARD', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160434ms]
-2016-08-08 16:26:20,912 -Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'orderDetails[2].personType' on 'class Action.OrderAction: Error setting expression 'orderDetails[2].personType' with value ['ELDER', ] -ERROR -com.opensymphony.xwork2.interceptor.ParametersInterceptor:34 -[http-nio-8080-exec-3:160436ms]
[]
其他简单的,比如order.number是可以取到值的。唯独Set<OrderDetail>取不到值。
求助!万分感谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论