找到你要的答案

Q:How use Angularjs ng-repeat in spring mvc

Q:如何使用AngularJS NG重复在Spring MVC

i want to create list of input by angularjs ng-repeat in spring mvc. so use this code

    <div ng-repeat="order in orders">
        <div>
            <input type="text" name="orders[{{$index}}].name">
            <input type="text" name="orders[{{$index}}].phone">
            <input type="text" name="orders[{{$index}}].mobile">
        </div>
   </div>

when i want to retrieve orders in spring controller this exception is catch.

   org.springframework.beans.InvalidPropertyException:
    Invalid property  'orders[]' of bean class Invalid index in property path 'orders[]';
    nested exception is java.lang.NumberFormatException: For input string: ""

我想用AngularJS NG重复在Spring MVC创建列表输入。所以使用这个代码

    <div ng-repeat="order in orders">
        <div>
            <input type="text" name="orders[{{$index}}].name">
            <input type="text" name="orders[{{$index}}].phone">
            <input type="text" name="orders[{{$index}}].mobile">
        </div>
   </div>

当我想在Spring控制器中检索订单时,这个异常被捕获。

   org.springframework.beans.InvalidPropertyException:
    Invalid property  'orders[]' of bean class Invalid index in property path 'orders[]';
    nested exception is java.lang.NumberFormatException: For input string: ""
answer1: 回答1:

You should do like this:

name="{{order[$index].name}}"//also, notice order not orders

你应该这样做:

name="{{order[$index].name}}"//also, notice order not orders
angularjs  spring  spring-mvc