java how to decode get url parameter received throw BeanParam(java如何解码接收到的url参数抛出BeanParam)
问题描述
我收到对此网络服务的GET响应
I receive a GET response to this web service
@GET
@Path("/nnnnnn")
public Response pfpfpfpf(@BeanParam NNNNNN n)
NNNNN 类有:
@QueryParam("parameter")
private String parameter;
对于那个参数有一个get和set.
And for that parameter there is a get and set.
我使用 查询参数 在 get 上发送请求,它会自动绑定到我的选项 NNNNN,一切都很好.
I send a request on a get with a query parameter and it is being bind automatically to my option NNNNN, everything is great.
但是,现在我在查询 url 中发送日语字符串.我在发送之前使用 UTF-8 对参数进行编码,我必须使用 UTF-8 对其进行解码.
but, now i am sending Japanese strings in the query url. I encode the paramter by UTF-8 before sending, and I have to decode them using UTF-8.
但我的问题是应该在哪里调用 URLDecoder?我试图在该参数的 getter 中调用它,但它没有用,我一直有类似 C3%98%C2%B4%C3%98%C2 之类的东西,而不是日文字符
but my question is where should I call the URLDecoder? i tried to call it in the getter of that parameter, but it didn't work, i kept having something like C3%98%C2%B4%C3%98%C2 instead of the Japanese characters
推荐答案
适合我的解决方案是:
在 servlet 上,我应该这样做:
on the servlet, i should do this:
request.setCharacterEncoding("UTF-8");
然后在 html 页面上我必须添加这个:
and then on the html page i had to add this:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
这篇关于java如何解码接收到的url参数抛出BeanParam的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:java如何解码接收到的url参数抛出BeanParam
基础教程推荐
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
