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
Release: 2016-06-24 12:11:25
Original
819 people have browsed it

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>
Copy after login

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.

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template