Home >Web Front-end >HTML Tutorial >Problem with jsp using URLDecoder to pass value in hyperlink_html/css_WEB-ITnose

Problem with jsp using URLDecoder to pass value in hyperlink_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:11:25832browse

When I used java.net.RULDecoder to transcode Chinese and then passed it to the servlet, I found that the result was different from the expected code. Here is the code:

<a href="<%=basePath%>ShowNews?newsId=<%=hotnews.getId() %>&&keywords=<%=java.net.URLEncoder.encode("我去","UTF-8") %>"><%=hotnews.getTitle() %></a>

The result was still in Chinese when passed


Reply to the discussion (solution)

Use js's encodeURIComponent()

In Firefox and 360 Speed ​​Browser, the address bar will be The encoding is automatically parsed, so Chinese will be displayed.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn