Escaping & in a URL

前端 未结 4 2068
孤城傲影
孤城傲影 2021-01-11 23:42

I am using jsps and in my url I have a value for a variable like say \"L & T\". Now when I try to retrieve the value for it by using request.getParameter I

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-12 00:22

    java.net.URLEncoder.encode("L & T", "utf8")
    

    this outputs the URL-encoded, which is fine as a GET parameter:

    L+%26+T
    

提交回复
热议问题