支付宝即时到账,传参乱码.
2016-06-17 15:37
405 查看
被郁闷了,支付宝即时转账,只能通过form 方式传参。然后,在本地的时候中文是ok 的但是一到传送到支付宝的时候就一直验签报错。
我问过支付宝的技术客服,确定 md5.sign()支持 汉字。 那问题就局限在传参的时候了。
然而不管我怎么设置,都没有办法解决乱码:
如下:
response.setHeader("Cache-Control", "no-cache");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
最后通过这篇文章(http://blog.csdn.net/hengyunabc/article/details/17056237)解决了问题,主要内容如下:
1.设置tomcat,conf/server.xml文件中,useBodyEncodingForURI="true":
[html]
view plain
copy
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" useBodyEncodingForURI="true"/>
2.增加一个filter:
[java]
view plain
copy
public class CodeFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}
3.在web.xml中配置filter:
[html]
view plain
copy
<filter>
<filter-name>CodeFilter</filter-name>
<filter-class>com.leg.filter.CodeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CodeFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
附上 支付宝接受异步返回的代码: http://xiongjiajia.iteye.com/blog/1327567 非常详尽。。。踩着巨人的肩膀啊。。。
我问过支付宝的技术客服,确定 md5.sign()支持 汉字。 那问题就局限在传参的时候了。
然而不管我怎么设置,都没有办法解决乱码:
如下:
response.setHeader("Cache-Control", "no-cache");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
最后通过这篇文章(http://blog.csdn.net/hengyunabc/article/details/17056237)解决了问题,主要内容如下:
tomcat里一劳永逸解决乱码问题
要想在tomcat中一劳永逸解决乱码问题,可以这样做:1.设置tomcat,conf/server.xml文件中,useBodyEncodingForURI="true":
[html]
view plain
copy
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" useBodyEncodingForURI="true"/>
2.增加一个filter:
[java]
view plain
copy
public class CodeFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}
3.在web.xml中配置filter:
[html]
view plain
copy
<filter>
<filter-name>CodeFilter</filter-name>
<filter-class>com.leg.filter.CodeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CodeFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
附上 支付宝接受异步返回的代码: http://xiongjiajia.iteye.com/blog/1327567 非常详尽。。。踩着巨人的肩膀啊。。。
相关文章推荐
- js传中文参数controller里获取参数乱码问题解决方法
- ajax提交到servelt获取参数有乱码的解决方法
- Js获取Url中参数及Url中传递中文参数乱码
- 不同文件系统导致的乱码,tomcat乱码等
- request.getParameter(“参数名”) 中文乱码解决方法
- servlet接收get请求参数乱码
- request请求参数乱码
- 一个被忽略的可能 会出现乱码问题的地方,tomcat 字符配置
- 从JSP前台页面传中文参数,到后台接受出现乱码,如何解决?
- java get获取地址栏参数乱码问题
- 服务器接收小程序wx.request参数乱码
- urlGet方式传中文乱码
- html表单控件的使用
- 谷歌学术上不了的解决办法
- PHP变量常量语言结构大小写敏感与…
- 最新OSSIM中国行之国电宣讲幻灯片(共116页)
- 论文查重网址
- 最新OSSIM中国行之国电宣讲幻灯片(共116页)
- 354. Russian Doll Envelopes
- 六维空间登陆网址