转换为&(& converted to & sometimes on request.getParameter(“url”) in jsp servlet)
我在JSP上输入非常简单的HTML:
<input type="text" name="url" value="" />用户在上面的输入中输入以下值:
http://www.example.com/param1=a¶m2=b在servlet方面,当我执行request.getParameter("url")我得到以下内容:
http://www.example.com/param1=a&param2=b如何在没有&情况下获取原始网址 来自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¶m2=bOn servlet side, when I do request.getParameter("url") I am getting following :
http://www.example.com/param1=a&param2=bHow can I get original URL without & 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)
更多推荐
发布评论