浏览 3832 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-09-30
同样的程序,发送到tomcat上的servlet就是正常的中文。 哪位有过相关经验的给指教一下啊,多谢! 附:相关部分代码 客户端: tSocket = new Socket("IP","PORT"); String tHttpHeader = "POST " + MerchantConfig.getTrustPayTrxURL() + " HTTP/1.1" + MerchantConfig.getTrustPayNewLine() + "Content-Type: application/x-www-form-urlencoded" + MerchantConfig.getTrustPayNewLine() + "Host: " + MerchantConfig.getTrustPayServerName() + ":" + MerchantConfig.getTrustPayServerPort() + MerchantConfig.getTrustPayNewLine() + "Accept: text/html, image/gif, image/jpeg, *; q=.2, * /*; q=.2" + MerchantConfig.getTrustPayNewLine() + "Accept-Charset: utf-8" + MerchantConfig.getTrustPayNewLine() + "Connection: keep-alive" + MerchantConfig.getTrustPayNewLine() + "Content-Length: "; System.out.println("tHttpHeader:" + tHttpHeader); //PrintWriter tOut = new PrintWriter(tSocket.getOutputStream(),true); PrintWriter tOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(tSocket.getOutputStream(), "utf-8"))); String test = new String("测试"); String tHttpRequest = tHttpHeader + tContentLength + MerchantConfig.getTrustPayNewLine() + MerchantConfig.getTrustPayNewLine() + test; System.out.println("tHttpRequest:" + tHttpRequest); tOut.print(tHttpRequest); tOut.flush(); 服务端: request.setCharacterEncoding(“utf-8”); requestMsg = getRequestMessage(request); System.out.println("requestMsg:" + requestMsg); 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |