0

I have a rest controller setup like below

@RequestMapping(value = {"getDataFromSpaceForType/{gridName}/{spaceName}/{dataType}/{fieldNames}/{criteria}"}, method = GET, produces = "application/json")
    public EntriesForTypeName getDataFromSpaceForType(@PathVariable Map<String, String> dataRequestVariables) throws Exception {

The last field criteria can contain multiple forward slashes. I am unable to handle such scenario. It breaks with 404 error

Also i dont know how many slashes might come, so it becomes impossible to create multiple methods.

Ambuj Jauhari
  • 1,187
  • 4
  • 26
  • 46

1 Answers1

0

If you know that your URL may contain slashes, all you have to do is to encode the URL before you send/use it.

If your front-end is angularJS then you can do it like this:

How to generate url encoded anchor links with AngularJS?

Or if you use jquery then:

URL Encode a string in jQuery for an AJAX request

Community
  • 1
  • 1
Moshe Arad
  • 3,587
  • 4
  • 18
  • 33
  • I tried encoding the url to something like this, but it didnt work. encodeURIComponent('/rest/query/getDataFromSpaceForType/local/privatespace/verifiedbill/feedmap/CalculatedMeasure=/bet/local/MXR/20160505/EOD_UK_IR_A2_20160505_1.txt) – Ambuj Jauhari Nov 23 '16 at 16:02