设为首页 加入收藏

TOP

常用JAVA方法
2011-06-09 12:55:21 来源: 作者: 【 】 浏览:696次 评论:0
<%!
stc_RSYB_Name stcRSYName1[];
stc_SYB_INF stcSYBINF1[];
%>
<%/*
String p = (String) session.getValue("access");
if (p==null || !p.equals("1")) {
response.sendRedirect("error.htm");
return;
}*/
%>
<%!
file://得到机器名字或IP
String get_Myhostname(javax.servlet.http.HttpServletRequest request){
String myhostname = null;
try{
myhostname = request.getRemoteHost();
myhostname = myhostname.toUpperCase();
}catch(Exception e){}
return myhostname;
}
file://处理空字符串
String dealNull(String str) {
String returnstr = null;
if (str == null) returnstr = "";
else returnstr = str;
return returnstr;
}
file://处理空对象
Object dealNull(Object obj){
Object returnstr = null;
if (obj == null) returnstr = (Object)("");
else returnstr = obj;
return returnstr;
}
int dealEmpty(String s) {
s = dealNull(s);
if (s.equals("")) return 0;
return Integer.parseInt(s);
}
String replace(String str,String substr,String restr){
String[] tmp = split(str,substr);
String returnstr = null;
if(tmp.length!=0) {
returnstr = tmp[0];
for(int i = 0 ; i < tmp.length - 1 ; i++)
returnstr =dealNull(returnstr) + restr +tmp[i+1];
}
return dealNull(returnstr);
}
String htmlEncode(String txt){
txt = replace(txt,"&","&");
txt = replace(txt,"&","&");
txt = replace(txt,""",""");
txt = replace(txt,""",""");
txt = replace(txt,"<","<");
txt = replace(txt,"<","<");
txt = replace(txt,">",">");
txt = replace(txt,">",">");
txt = replace(txt," "," ");
您看到此篇文章时的感受是:
Tags: 责任编辑:administrator
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到QQ空间
分享到: 
上一篇一个用Class.forName()做的动态装.. 下一篇关于cachedRowSet的一篇文章(java..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

相关栏目

最新文章

图片主题

热门文章

推荐文章

相关文章

广告位