简体   繁体   中英

JS - Submit parameter's value with “&”

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

encodeURIComponent(string)会将URL中具有特殊含义的字符(例如& )转换为它们的转义序列。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM