文件路径等字符串 斜杠 反斜杠 替换
str.replaceAll("/","\\\\");
jsp 引入 类的时候 一定要注意类的确切位置
例如 : User 包目录 com.tian.entity.User
在jsp 中 引入 <%@ page import="com.tian.*"%> 这样是不对的必须
<%@ page import="com.tian.entity.*"%> 正确
.getAttribute() 使用的时候 注意下面的情况
错误
List<Infos> infos=(List<Infos>)request.getAttribute("list");
正确
List infos =(List) request.getAttribute("list");
for(int i=0;i<info.size();i++){
Infos info=(Infos)infos.get(i);
}
转义字符
- /n 回车(/u000a)
- /t 水平制表符(/u0009)
- /b 空格(/u0008)
- /r 换行(/u000d)
- /f 换页(/u000c)
- /' 单引号(/u0027)
- /" 双引号(/u0022)
- // 反斜杠(/u005c)
- /ddd 三位八进制
- /udddd 四位十六进制
在一个extjs 的panel 及其子类中 获取 button ,items 组建
var b1=form.items.items[0];
b1.setValue(2);//此b1 类型为 textfield
var b2=form.items.items[1];
b2.setValue('bbbb');
用于浏览器显示等长度(及等像素宽度)字符串时候字符串截取
/**
* 根据传入正则表达式匹配arg字符串 返回 正则表达式匹配成功次数
* @param arg
* @param regex
* @return
*/
public synchronized static int regexCount(String arg,String regex){
if(arg==null)return 0;
if(arg.length()<=0)return 0;
int length=0;
char last=0;
String[]strs=arg.split(regex);
if(strs.length>0){
length= strs.length-1;
int i=1;
last=arg.charAt(arg.length()-i);
while(last<='z'){
length++;
i++;
last=arg.charAt(arg.length()-i);
}
}
/**判断是否全是字母组成*/
if(strs.length==0){
char[] chs=arg.toCharArray();
for(char ch:chs){
if(ch>'z')return length;
}
return arg.length();
}
return length;
}
public static int regexCount(String arg){
return regexCount(arg, REGEX);
}
/**
* 设定所需截取的字符串长度截取等长像素的字符串,
* 用于浏览器显示时候每条字符串像素长度一致
* @param arg
* @param length
* @param lastStr
* @return
* @throws Exception
*/
public synchronized static String cutLongString(String arg,int length,String lastStr)throws Exception{
if(length<=0)throw new Exception("字符串缩短尺寸 length :"+length+" 小于最小值");
if(arg==null||"".equals(arg))return arg;
if(arg.length()<=length)return arg;
int l=regexCount(arg.substring(0, length));
if(l!=0){
int len=length+l/2;
if(arg.length()<=len)return arg;
int f=l;
while(arg.length()>len){
int ll=regexCount(arg.substring(0,len));
if(f==ll){
length=len;
break;
}
len=len-f/2+ll/2;
f=ll;
}
if(arg.length()<=length)return new StringBuffer(arg.substring(0, length)).toString();
}
return new StringBuffer(arg.substring(0, length)).append(lastStr).toString();
}
@Test
public void test_cutLongString() throws Exception{
System.out.println(cutLongString("中国需要中国需要中国需要中国需要bbb", 17,".."));
System.out.println(cutLongString("中国需bbbbbbbbb要bbb", 17,".."));
System.out.println(cutLongString("中国需bbbbbbbbbbbbb《》bbbbbbb<>bb要bbb", 17,".."));
}
svn 本地连接配置 :
file:///svn管理文件目录..
示例 : file:///D:/svn_repository
tomcat 容器工程 浏览器显示图表
部署在tomcat中的项目在运行的时候,地址栏都是那个标志的小猫图标,很多时候我们需要修改这个图标。
其实方法很简单,系统读取这个标志的时候先从你的项目的根目录下读看有没有favicon.ico文件,如果有直接显示这个图标,如果没有,则会去 webapps/root/下找这个文件,如果这两个地方都没有,则就显示IE图标。
当然,对于有的浏览器这样做就可以了,但是有一些浏览器必须直接在页面中加入
- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
其中 href 的值就是地址栏图标的路径,当然这个可以是相对的,也可是绝对的,现在的值表示这个图标文件在项目的根目录下,还可以改成下面这样
- <link rel="shortcut icon" href="http://www.weather.com.cn/favicon.ico" type="image/x-icon" />
- <link rel="shortcut icon" href="http://www.weather.com.cn/favicon.ico" type="image/x-icon" />
这样的话,如果你想每个页面显示的地址栏图标都不一样,也是可以实现的
Math 对象方法
FF: Firefox, IE: Internet Explorer
方法 | 描述 | FF | IE |
---|---|---|---|
abs(x) | 返回数的绝对值。 | 1 | 3 |
acos(x) | 返回数的反余弦值。 | 1 | 3 |
asin(x) | 返回数的反正弦值。 | 1 | 3 |
atan(x) | 以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值。 | 1 | 3 |
atan2(y,x) | 返回从 x 轴到点 (x,y) 的角度(介于 -PI/2 与 PI/2 弧度之间)。 | 1 | 3 |
ceil(x) | 对数进行上舍入。 | 1 | 3 |
cos(x) | 返回数的余弦。 | 1 | 3 |
exp(x) | 返回 e 的指数。 | 1 | 3 |
floor(x) | 对数进行下舍入。 | 1 | 3 |
log(x) | 返回数的自然对数(底为e)。 | 1 | 3 |
max(x,y) | 返回 x 和 y 中的最高值。 | 1 | 3 |
min(x,y) | 返回 x 和 y 中的最低值。 | 1 | 3 |
pow(x,y) | 返回 x 的 y 次幂。 | 1 | 3 |
random() | 返回 0 ~ 1 之间的随机数。 | 1 | 3 |
round(x) | 把数四舍五入为最接近的整数。 | 1 | 3 |
sin(x) | 返回数的正弦。 | 1 | 3 |
sqrt(x) | 返回数的平方根。 | 1 | 3 |
tan(x) | 返回角的正切。 | 1 | 3 |
toSource() | 返回该对象的源代码。 | 1 | - |
valueOf() | 返回 Math 对象的原始值。 | 1 | 4 |