转换为&(& converted to & sometimes on request.getParameter(“url”) in jsp servlet)

编程入门 行业动态 更新时间:2024-10-26 08:33:04
转换为&(& converted to & sometimes on request.getParameter(“url”) in jsp servlet)

我在JSP上输入非常简单的HTML:

<input type="text" name="url" value="" />

用户在上面的输入中输入以下值:

http://www.example.com/param1=a&param2=b

在servlet方面,当我执行request.getParameter("url")我得到以下内容:

http://www.example.com/param1=a&amp;param2=b

如何在没有&amp;情况下获取原始网址 来自request.getParameter ?

I have very simple input on HTML on JSP:

<input type="text" name="url" value="" />

User enters following value in above input:

http://www.example.com/param1=a&param2=b

On servlet side, when I do request.getParameter("url") I am getting following :

http://www.example.com/param1=a&amp;param2=b

How can I get original URL without &amp; from request.getParameter?

最满意答案

我终于找到了解决方案。 只需使用org.apache.commons.lang.StringEscapeUtils.unescapeHtml(url)来逃避任何“&a mp;” (因为html编码而逃避任何字符)

I finally found the solution. Just use org.apache.commons.lang.StringEscapeUtils.unescapeHtml(url) to escape any "&a m p;" (for that matter to escape any characters due to html encoding)

更多推荐

本文发布于:2023-08-04 02:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408795.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   converted   amp   request   servlet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!