0

I have a problem with the parameter that is send through URL endpiont. The URL is constructed pretty typical way:

var url = 'Url' + 'info/' + '/getInstallmentScheduleInfoList/' + invoice_number;

The problem is with the invoice_number. Basicly there are some String values but sometimes it takes String that has '/' character. For example invoice_number = '2021/153ABC'. In this case backend controller expects endpiont with two different parameters: '2021' and '153ABC'. Obviously it is wrong and NotFoundException is thrown. The values are taken from the outter world and I wonder if there is some way to fix it in my code. Here is the signature and annotation of my controller code:

@RequestMapping(value = "/getInstallmentScheduleInfoList/{installmentInvoiceNumber}", method = RequestMethod.GET)
public @ResponseBody
List<RecordWrapper<InstallmentScheduleInfo>> getInstallmentScheduleInfoList(@PathVariable String installmentInvoiceNumber) 
macqo
  • 11
  • 2

1 Answers1

0

The parameter should be passed as encoded parameter. After encoding the value will become something like "2021%2F153ABC". Which will be processed correctly. And this is standard way to pass parameters to URLs.

In java we have URLEncoder and URLDecoder class for that. While you can find some online encoder and decoder also.

Gaurav Jeswani
  • 4,410
  • 6
  • 26
  • 47