- 浏览: 45268 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
ljl961890233bear:
我也遇到这个问题了。。。
解决UNION速度慢 -
z-one:
楼主厉害 我刚好遇到类似问题,先试试看
解决UNION速度慢
方案一
================
[页面传参方式:]
例: "aaa.do?val="+encodeURI(encodeURI("要传的值"))
[参数获取方式:]
String val=request.getParameter("val");
val=java.net.URLDecoder.decode(val,"utf-8");
特殊符号仍然有问题
方案二
================
[页面传参方式:]
例: "aaa.do?val="+escape(escape("要传的值"))
[参数获取方式:]
String val=request.getParameter("val");
val=Escape.unescape(val);
escape() 方法:
采用ISO Latin字符集对指定的字符串进行编码。所有的空格符、标点符号、特殊字符以及其他非ASCII字符都将被转化成%xx格式的字符编码(xx等于该字符在字符集表里面的编码的16进制数字)。比如,空格符对应的编码是%20。unescape方法与此相反。不会被此方法编码的字符: @ * / +
英文解释:MSDN JScript Reference: The escape method returns a string value (in Unicode format) that contains the contents of [the argument]. All spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the character. For example, a space is returned as "%20."
Edge Core Javascript Guide: The escape and unescape functions let you encode and decode strings. The escape function returns the hexadecimal encoding of an argument in the ISO Latin character set. The unescape function returns the ASCII string for the specified hexadecimal encoding value.
encodeURI() 方法:把URI字符串采用UTF-8编码格式转化成escape格式的字符串。不会被此方法编码的字符:! @ # $& * ( ) = : / ; ? + '
英文解释:MSDN JScript Reference: The encodeURI method returns an encoded URI. If you pass the result to decodeURI, the original string is returned. The encodeURI method does not encode the following characters: ":", "/", ";", and "?". Use encodeURIComponent to encode these characters. Edge Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character
encodeURIComponent() 方法:把URI字符串采用UTF-8编码格式转化成escape格式的字符串。与encodeURI()相比,这个方法将对更多的字符进行编码,比如 / 等字符。所以如果字符串里面包含了URI的几个部分的话,不能用这个方法来进行编码,否则 / 字符被编码之后URL将显示错误。不会被此方法编码的字符:! * ( )
英文解释:MSDN JScript Reference: The encodeURIComponent method returns an encoded URI. If you pass the result to decodeURIComponent, the original string is returned. Because the encodeURIComponent method encodes all characters, be careful if the string represents a path such as /folder1/folder2/default.html. The slash characters will be encoded and will not be valid if sent as a request to a web server. Use the encodeURI method if the string contains more than a single URI component. Mozilla Developer Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character.
因此,对于中文字符串来说,如果不希望把字符串编码格式转化成UTF-8格式的(比如原页面和目标页面的charset是一致的时候),只需要使用escape。如果你的页面是GB2312或者其他的编码,而接受参数的页面是UTF-8编码的,就要采用encodeURI或者encodeURIComponent。
另外,encodeURI/encodeURIComponent是在javascript1.5之后引进的,escape则在javascript1.0版本就有。
英文注释:The escape() method does not encode the + character which is interpreted as a space on the server side as well as generated by forms with spaces in their fields. Due to this shortcoming, you should avoid use of escape() whenever possible. The best alternative is usually encodeURIComponent().Use of the encodeURI() method is a bit more specialized than escape() in that it encodes for URIs [REF] as opposed to the querystring, which is part of a URL. Use this method when you need to encode a string to be used for any resource that uses URIs and needs certain characters to remain un-encoded. Note that this method does not encode the ' character, as it is a valid character within URIs.Lastly, the encodeURIComponent() method should be used in most cases when encoding a single component of a URI. This method will encode certain chars that would normally be recognized as special chars for URIs so that many components may be included. Note that this method does not encode the ' character, as it is a valid character within URIs.
================
[页面传参方式:]
例: "aaa.do?val="+encodeURI(encodeURI("要传的值"))
[参数获取方式:]
String val=request.getParameter("val");
val=java.net.URLDecoder.decode(val,"utf-8");
特殊符号仍然有问题
方案二
================
[页面传参方式:]
例: "aaa.do?val="+escape(escape("要传的值"))
[参数获取方式:]
String val=request.getParameter("val");
val=Escape.unescape(val);
escape() 方法:
采用ISO Latin字符集对指定的字符串进行编码。所有的空格符、标点符号、特殊字符以及其他非ASCII字符都将被转化成%xx格式的字符编码(xx等于该字符在字符集表里面的编码的16进制数字)。比如,空格符对应的编码是%20。unescape方法与此相反。不会被此方法编码的字符: @ * / +
英文解释:MSDN JScript Reference: The escape method returns a string value (in Unicode format) that contains the contents of [the argument]. All spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the character. For example, a space is returned as "%20."
Edge Core Javascript Guide: The escape and unescape functions let you encode and decode strings. The escape function returns the hexadecimal encoding of an argument in the ISO Latin character set. The unescape function returns the ASCII string for the specified hexadecimal encoding value.
encodeURI() 方法:把URI字符串采用UTF-8编码格式转化成escape格式的字符串。不会被此方法编码的字符:! @ # $& * ( ) = : / ; ? + '
英文解释:MSDN JScript Reference: The encodeURI method returns an encoded URI. If you pass the result to decodeURI, the original string is returned. The encodeURI method does not encode the following characters: ":", "/", ";", and "?". Use encodeURIComponent to encode these characters. Edge Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character
encodeURIComponent() 方法:把URI字符串采用UTF-8编码格式转化成escape格式的字符串。与encodeURI()相比,这个方法将对更多的字符进行编码,比如 / 等字符。所以如果字符串里面包含了URI的几个部分的话,不能用这个方法来进行编码,否则 / 字符被编码之后URL将显示错误。不会被此方法编码的字符:! * ( )
英文解释:MSDN JScript Reference: The encodeURIComponent method returns an encoded URI. If you pass the result to decodeURIComponent, the original string is returned. Because the encodeURIComponent method encodes all characters, be careful if the string represents a path such as /folder1/folder2/default.html. The slash characters will be encoded and will not be valid if sent as a request to a web server. Use the encodeURI method if the string contains more than a single URI component. Mozilla Developer Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character.
因此,对于中文字符串来说,如果不希望把字符串编码格式转化成UTF-8格式的(比如原页面和目标页面的charset是一致的时候),只需要使用escape。如果你的页面是GB2312或者其他的编码,而接受参数的页面是UTF-8编码的,就要采用encodeURI或者encodeURIComponent。
另外,encodeURI/encodeURIComponent是在javascript1.5之后引进的,escape则在javascript1.0版本就有。
英文注释:The escape() method does not encode the + character which is interpreted as a space on the server side as well as generated by forms with spaces in their fields. Due to this shortcoming, you should avoid use of escape() whenever possible. The best alternative is usually encodeURIComponent().Use of the encodeURI() method is a bit more specialized than escape() in that it encodes for URIs [REF] as opposed to the querystring, which is part of a URL. Use this method when you need to encode a string to be used for any resource that uses URIs and needs certain characters to remain un-encoded. Note that this method does not encode the ' character, as it is a valid character within URIs.Lastly, the encodeURIComponent() method should be used in most cases when encoding a single component of a URI. This method will encode certain chars that would normally be recognized as special chars for URIs so that many components may be included. Note that this method does not encode the ' character, as it is a valid character within URIs.
发表评论
-
java基础框架技巧
2012-07-14 16:43 01.使用泛型 -
ANT自动发布
2012-01-18 16:18 0<?xml version="1.0&q ... -
Property文件读取
2012-01-10 15:54 0public class Properties { ... -
eclipse 实用插件收藏
2011-12-07 11:30 736SVN插件 http://subclipse.tigris ... -
收藏 图片缩放处理
2011-11-04 15:55 0package graphicsTest; imp ... -
MS932转换SHIFT_JIS特殊字符处理
2011-11-03 15:56 0StringBuffer strBuf = new Strin ... -
SAX解析XML
2011-11-03 15:22 594// イニシャルコンテキスト取得 Context ... -
JAVA并发编程笔记
2011-08-29 09:12 01.多进程技术不是也 ... -
设计模式串烧
2011-08-15 15:45 01.简单工厂模式 a工厂模式分为简单工厂模式,工厂方法模式, ... -
再读JAVA编程思想笔记
2011-08-04 14:52 0http://caterpillar.onlyfun.net/ ... -
SWT BROWSER 爬虫代码
2011-05-20 16:05 0package com.pceggs.lucky.rob ... -
处理中文文件名下载问题
2011-05-18 10:06 582String filePath = super.rea ... -
国际化
2011-04-08 13:43 0package xfile.util; impor ... -
Robot自动踩人气(二)
2011-04-08 13:38 0com.pceggs.lucky.ui包 pa ... -
Robot自动踩人气(一)
2011-04-08 13:23 0com.pceggs.lucky.robot包 p ... -
工具类方法收集
2011-04-08 13:18 0/** * 获取该资源 ... -
弹出文件选择框
2011-03-29 14:19 688<input type="text" ... -
收藏 TOMCAT优化
2011-03-26 13:42 583在Tomcat和应用程序进行了压力测试后,如果您对应用程序的性 ... -
Java中用Robot类控制鼠标和键盘的方法
2011-03-24 13:03 0Java中用Robot类控制鼠标和键盘的方法 时间:2011- ... -
CheckUtil
2011-01-10 21:03 0import java.io.UnsupportedEncod ...
相关推荐
get方式传参中文乱码问题的解决方案
get中文传参(解码) new String()
java实现调用httpclient接口的类和方法,包括了get和post传参方式,简单易懂
以GET或者POST方式向网页提交参数!我们知道如 果是GET的请求方式,那么所有参数都直接放到页面的URL后面用问号与页面地址隔开,每个参数用&隔开
Unity 中通过UnityWebRequest 以GET形式传authorization 的参数请求数据。 注意: 以Header头文件的形式发送请求,authorization要放入请求头部。 以头文件形式发起请求进行Token验证,token为Authorization中的...
参看文档:http://blog.csdn.net/sinat_29398599/article/details/52880036
SpringMVC解决GET请求时中文乱码的问题.rar
能处理所有servlet里的乱码,让你的网页里不在有乱码
修改Tomcat默认编码消除get方式传递参数出现中文乱码修改Tomcat默认编码消除get方式传递参数出现中文乱码修改Tomcat默认编码消除get方式传递参数出现中文乱码修改Tomcat默认编码消除get方式传递参数出现中文乱码
关于java中使用表单get方法传值出现乱码问题的解答。详细简单,便于学习使用。
JSP中 ajax的get请求的中文乱码问题的解决方法.pdf 学习资料 复习资料 教学资源
tomcat get提交中文乱码解决方案,修改tomcat server.xml 中以下为
get post 请求中文乱码 处理方式一(小实例+说明文档)
过滤器实现get请求乱码问题 过滤器实现get请求乱码问题 过滤器实现get请求乱码问题
PHP接收GET中文参数乱码深入研究.
Word文档,get传参讲解,喜欢的朋友可以下载下来看看,讲的很不错
IE 浏览器在get请求下中文乱码的问题
get请求乱码问题 java
主要介绍了PHP采用get获取url汉字出现乱码的解决方法,是很多PHP程序员都曾遇到的问题,非常具有实用价值,需要的朋友可以参考下
然后,我们发送一个200响应代码和响应长度,表示回调已成功接收。...这样,第三方就可以使用GET请求问号传参的方式调用你的回调服务了。你可以在回调服务中添加更多的逻辑来处理这些参数,并根据需要生成响应消息