SPRING --- How to submit an array of object to controller

As title,

i using angularjs to submit

my spring controller:

@RequestParam(value = "hashtag[]") hashtag[] o

above are work for array parameter but not an array object

my js script:

$http({
         method: 'POST',
         url: url,
         data: $.param({
                hashtag : [{label:"success",value:"ok"},{label:"success",value:"ok"},{label:"success",value:"ok"}],
               }),
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' }  });

i observe from chrome, the form data is

    hashtag[0][label]:success
    hashtag[0][value]:10

    hashtag[1][label]:success
    hashtag[2][value]:10

    hashtag[3][label]:success   
    hashtag[3][value]:10

But the Spring show me

org.springframework.web.bind.MissingServletRequestParameterException: Required hashtag[] parameter 'id[]' is not present

Previously i was able to receive an array of parameters, but not an object. so can someone enlighten me?

Try Using @ModelAttribute

Create a new Java class HashtagList like given below

public class HashTagList {

    private List<HashTag> hashTag;

    public List<HashTag> getHashTag() {
        return hashTag;
    }

    public void setHashTag(List<HashTag> hashTag) {
        this.hashTag = hashTag;
    }
}

and in your controller method

@ModelAttribute("hashtag") HashTagList hashTagList

Is the java class name hashtag or HashTag ?

Try @RequestParam(value = "hashtag") hashtag[] o

Given that you have a class named hashtag havinf label and value attributes.

Because it is a POST request you can use @RequestBody annotation and create a DTO class to map the data you are sending or maybe even use your domain object. For example, why not create reusable POJO class that can hold key->value pairs like:

@JsonPropertyOrder({"label", "value"})
public final class Pair<K,V> implements Map.Entry<K,V>, Serializable {
   private final K key;
   private final V value;

   @JsonCreator
   public Pair(@JsonProperty("label")K key, @JsonProperty("value")V value) {
       this.key = key;
       this.value = value;
   }
   // ... rest of the implementation
}

Note: I have assumed here you are using Jackson mapper, hence the JSON annotations. Next step is to get the class that will hold the data structure you are sending from your client:

public class HashTags implements Serializable {
    List<Pair<String, String>> hashtag = new ArrayList<>();
   // ... rest of the implementation
}

Then in your controller you will have to do something like:

@RequestBody HashTags entity