| 十六进制值 | |||
| 1. | + | URL 中+号表示空格 | %2B |
| 2. | 空格 | URL中的空格可以用+号或者编码 | %20 |
| 3. | / | 分隔目录和子目录 | %2F |
| 4. | ? | 分隔实际的 URL 和参数 | %3F |
| 5. | % | 指定特殊字符 | %25 |
| 6. | # | 表示书签 | %23 |
| 7. | & | URL 中指定的参数间的分隔符 | %26 |
| 8. | = | URL 中指定参数的值 | %3D |
data2=data2.replace(/\%/g,"%25");
data2=data2.replace(/\#/g,"%23");
data2=data2.replace(/\&/g,"%26");
1,代码中可以使用
URLEncoder.encode(url, "UTF-8");
<script>
(function(){
function setArticleH(btnReadmore,posi){
var winH = $(window).height();
var articleBox = $("div.article_content");
var artH = articleBox.height();
if(artH > winH*posi){
articleBox.css({
\'height\':winH*posi+\'px\',
\'overflow\':\'hidden\'
})
btnReadmore.click(function(){
if(typeof window.localStorage === "object" && typeof window.csdn.anonymousUserLimit === "object"){
if(!window.csdn.anonymousUserLimit.judgment()){
window.csdn.anonymousUserLimit.Jumplogin();
return false;
}else if(!currentUserName){
window.csdn.anonymousUserLimit.updata();
}
}
articleBox.removeAttr("style");
$(this).parent().remove();
})
}else{
btnReadmore.parent().remove();
}
}
var btnReadmore = $("#btn-readmore");
if(btnReadmore.length>0){
if(currentUserName){
setArticleH(btnReadmore,3);
}else{
setArticleH(btnReadmore,1.2);
}
}
})()
</script>
</article>
2.判断是否含有特殊字符
/**
* 判断是否含有特殊字符
*
* @param str
* @return true为包含,false为不包含
*/
public static boolean isSpecialChar(String str) {
String regEx = "[ _`~!@#$%^&*()+=|{}\':;\',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
return m.find();
}
public static final String DEFAULT_QUERY_REGEX = "[!$^&*+=|{}\';\'\",<>/?~!#¥%……&*——|{}【】‘;:”“\'。,、?]";
/**
* 判断查询参数中是否以特殊字符开头,如果以特殊字符开头则返回true,否则返回false
*
* @param value
* @return
* @see {@link #getQueryRegex()}
* @see {@link #DEFAULT_QUERY_REGEX}
*/
public boolean specialSymbols(String value) {
if (StringUtil.isBlank(value)) {
return false;
}
Pattern pattern = Pattern.compile(getQueryRegex());
Matcher matcher = pattern.matcher(value);
char[] specialSymbols = getQueryRegex().toCharArray();
boolean isStartWithSpecialSymbol = false; // 是否以特殊字符开头
for (int i = 0; i < specialSymbols.length; i++) {
char c = specialSymbols[i];
if (value.indexOf(c) == 0) {
isStartWithSpecialSymbol = true;
break;
}
}
return matcher.find() && isStartWithSpecialSymbol;
}
/**
* 获取查询过滤的非法字符
*
* @return
*/
protected String getQueryRegex() {
return DEFAULT_QUERY_REGEX;
}