Question

I´m working with a .js referring to a form.

In a function it sets the form's action and then submit it.

document.forms[0].action = "FileController.do?action=genFile&fileType="+ft+"&answType="+at;
document.forms[0].submit();

The problem is that answType's value sometimes has an "&" on it, like "M&M", so when I try to get that value like this:

String answer = request.getParameter("answType");

I only get the first "M" and lost the rest of the value.

I know that's because parameters are separated by "&".

But is there a workaround for this?

I can't change the original data.

Thank's

Was it helpful?

Solution

encodeURIComponent(string) will convert characters with special meaning in URLs (such as &) to their escape sequences.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top