2

Is it possible to use @RequestMapping in form of (or different) :

  @RequestMapping(value = {"/dirA/{listOfids}" }, method = RequestMethod.GET) 

so that path /dirA/2/3/4/5/6(...) will be still resolved into it? Or what would be the best way to handle similar request and pass array of some ids/properties?

xwhyz
  • 1,444
  • 4
  • 21
  • 45

2 Answers2

3

You cannot do that via a PathVariable, but you can pass an array via a RequestParam

Check How to pass an array within a query string? and @RequestParam array mapping issues for more info.

Community
  • 1
  • 1
Ricardo Veguilla
  • 3,107
  • 1
  • 18
  • 17
  • @xwhyz, You should provide upvote or even accept the answer if you find it useful! this is why people will get motivation to answer your questions! – Sazzadur Rahaman Sep 20 '14 at 17:49
0

Not in the way you're describing. You can do something like this though

@RequestMapping(value = "/dirA/{listOfIds}", method = RequestMethod.GET)
public List<MyObject> find(@PathVariable Integer[] listOfIds)

And then use the path /dirA/2,3,4,5,6 (i.e. with commas instead of slashes)

Cavyn VonDeylen
  • 4,189
  • 9
  • 37
  • 52
  • Can you tell how to access in controller if i am passing data as ["download_1551771319518.jpg","download%20(1)_1551771319518.jpg"]? – Sachin HR Mar 05 '19 at 07:47