---
title: "Binding a list in @RequestParam"  
description: "Binding a list in @RequestParam"  
author: "Anonymous User"  
published: 2015-12-16  
updated: 2015-12-16  
canonical: https://www.mindstick.com/forum/33742/binding-a-list-in-requestparam  
category: "java"  
tags: ["java", "collection"]  
reading_time: 2 minutes  

---

# Binding a list in @RequestParam

I'm sending some [parameters](https://www.mindstick.com/articles/87/passing-parameters-in-c-sharp) from a form in this way:\

```
myparam[0]     : 'myValue1'myparam[1]     : 'myValue2'myparam[2]     : 'myValue3'otherParam     : 'otherValue'anotherParam   : 'anotherValue' ...
```

I know I can get all the params in the [controller method](https://www.mindstick.com/forum/157312/how-to-call-a-controller-method-after-load-view-successfully-in-mvc-4) by adding a [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) like\

```
public String controllerMethod(@RequestParam Map<String, String> params){    ....}
```

I want to bind the parameters myParam[] (not the other ones) to a list or [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) (anything that keeps the index [order](https://www.mindstick.com/articles/12276/how-timely-order-deliveries-can-improve-customer-experience)), so I've tried with a syntax like:\

```
public String controllerMethod(@RequestParam(value="myParam") List<String> myParams){    ....}
```

and\

```
public String controllerMethod(@RequestParam(value="myParam") String[] myParams){    ....}
```

but none of them are [binding](https://www.mindstick.com/blog/146/dynamic-binding-in-c-sharp) the myParams. Even when I add a [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) to the map it is not able to bind the params:\

```
public String controllerMethod(@RequestParam(value="myParam") Map<String, String> params){    ....}
```

Is there any syntax to bind some params to a list or array without having to create an object as @ModelAttribute with a list [attribute](https://www.mindstick.com/blog/221/attributes-reflection) in it?

## Replies

### Reply by Anonymous User

Arrays in @RequestParam are used for binding several parameters of the same name:\

```
myparam=myValue1&myparam=myValue2&myparam=myValue3
```

If you need to bind @ModelAttribute-style indexed parameters, I guess you need @ModelAttribute anyway.\
Or you could just do it that way:\

```
public String controllerMethod(@RequestParam(value="myParam[]") String[] myParams){    ....}
```

That works for example for forms like this:\

```
<input type="checkbox" name="myParam[]" value="myVal1" /><input type="checkbox" name="myParam[]" value="myVal2" />
```


---

Original Source: https://www.mindstick.com/forum/33742/binding-a-list-in-requestparam

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
