How to encode a URL with the special character “percentage”?

前端 未结 4 1625
你的背包
你的背包 2021-01-24 08:43

I am trying to use the encodeURL method in a jsp to encode a URL with \"%\" symbol.

response.encodeURL(/page1/page2/view.jsp?name=Population of 91% in

4条回答
  •  温柔的废话
    2021-01-24 08:57

    In your example, you can use the c:url and c:param tags:

    
        
    
    

    In particular, the c:param tag will url-encode the value attribute. I just ran into a situation where I needed to generate a URL with a querystring containing a value that started with a pound sign. Without url-encoding, the pound sign was interpreted by the browser as the start of the anchor portion. I added the c:param tag, and the pound sign was encoded, allowing expected behavior when following the link.

提交回复
热议问题