divine
divine

Reputation: 4912

@RequestParam not accepting '&' in a string sent from request, stores all characters before & and truncates the rest

Value sent from ajax: Droit & stratégie des affaires au Maroc

@RequestMapping(value = "getValue")
@ResponseBody
public void getTOCFromML(@RequestParam("doc_id") String doc_id, HttpServletResponse response,HttpServletRequest request)
{
System.out.println(doc_id);
}

output: Droit
Expected output: Droit & stratégie des affaires au Maroc

@RequestParam("doc_id") stores the value before & character and ignores the rest of the characters (for some security purpose i believe) .

But i need the full string for further execution.

Please let me know how to make this work

Update1: Only '&' character causing the problem for me.
when below value given as input, it works fine

Value : La Semaine Juridique Notariale et Immobilière 

Update2: i used encodeURIComponent(string) in javascript ajax req. its working now. thankyou

Upvotes: 0

Views: 539

Answers (1)

Shifat
Shifat

Reputation: 762

Use

   URLEncoder.encode()

Hope it will help.

Upvotes: 1

Related Questions