首页>代码>ssm分页查询实例 ,只需一个查询就可以>/page/src/com/common/paginate/StringUitl.java
001package com.common.paginate;
002 
003import java.util.HashMap;
004import java.util.Map;
005import java.util.regex.Pattern;
006 
007public class StringUitl {
008    /**
009     *  判断一个字符串是否为空
010     * @param str
011     * @return
012     */
013    public static boolean IsNull(String str){
014        if(str==null||"".equals(str)||"".equals(str.trim())){
015            return true;
016        }
017        return false;
018    }
019    /**
020     *  判断一个字符串是否为非空
021     * @param str
022     * @return
023     */
024    public static boolean IsNotNull(String str){
025        if(str==null||"".equals(str)||"".equals(str.trim())){
026            return false;
027        }
028        return true;
029    }
030    /**
031     * 转换成小写
032     *@author wangym
033     *@date Aug 15, 2012 9:16:41 AM
034     * @param src
035     * @return
036     */
037    public static String tranStartCharToLower(String src)
038    {
039        if (src == null || src.equals(""))
040        {
041             
042            return null;
043        } else
044        {
045            char target = src.charAt(0);
046            return src.replaceFirst((new StringBuilder(String.valueOf(target))).toString(), (new StringBuilder(String.valueOf(Character.toLowerCase(src.charAt(0))))).toString());
047        }
048    }
049    /**
050     * 去掉字符串两端的空格
051     *@author wangym
052     *@date Aug 15, 2012 9:13:47 AM
053     * @param str
054     * @return
055     */
056    public static String toTrim(String str)
057    {
058        if (str == null)
059            return "";
060        if (str.trim().equalsIgnoreCase("null"))
061            return "";
062        else
063            return str.trim();
064    }
065    /**
066     * 获取项目路径
067     * @return
068     */
069    public static String getWebRootPath(){
070        String filePath=new StringUitl().getClass().getResource("/").getPath();
071        if(filePath.indexOf("/")==0){          
072            filePath=filePath.substring(1, filePath.lastIndexOf("WEB-INF"));
073        }else{         
074            filePath=filePath.substring(0, filePath.lastIndexOf("WEB-INF"));
075        }
076        return filePath;
077    }
078 
079    public static void main(String[] args) {
080        System.out.println(StringUitl.getWebRootPath());
081    }
082     
083    /**
084     * 如果是null返回空字符串
085     * @return arg
086     */
087    public static String SiftNull(String arg){
088        String rt = "";
089        if(arg != null && !"".equals(arg)){
090            rt = arg;
091        }
092        return rt;
093    }
094    /**
095     * 如果是null返回空字符串
096     * @return arg
097     */
098    public static String SiftNull(Object arg){
099        String rt = "";
100        if(arg != null){
101            rt = arg.toString();
102        }
103        return rt;
104    }
105    /**
106     * 获取报表公共的map对象
107     * @return
108     */
109    public static Map<String, Object>  getReportHashMap(){
110        Map<String, Object> map = new HashMap<String, Object>();
111        //Code条件限制
112        map.put("condition_code", "code <> 'yw'");
113        //mallCode条件限制
114        map.put("condition_mallCode", "mall_code <> 'yw'");
115        //buyMallCode条件限制
116        map.put("condition_buyMallCode", "buy_mall_code <> 'yw'");
117        //sellMallCode条件限制
118        //map.put("condition_sellMallCode", "sell_mall_code NOT IN ('yw')");
119        //portalorg_ou条件限制
120        map.put("condition_portalorgOU", "portalorg_ou <> '00330040731'");
121        //portalorg_ou条件限制
122        map.put("condition_provinceOU", "province_orgou <> '00330040731'");
123        //shopType条件限制
124        map.put("condition_shopType", "shopType NOT IN (2,3,5,8)");
125        //shopType条件限制
126        map.put("condition_pid", "pid = -1");
127        //下拉框条件限制yw
128        map.put("yw", "'yw'");
129        //查询条件中的group by条件限制
130        map.put("condition_groupBy", "");
131        return map;
132    }
133     
134    /**
135     * 获取组装List的共用map对象
136     * @return
137     */
138    public static Map getCombineListMap(){
139        Map map = new HashMap();
140        map.put("mall_code", "zongji");
141        map.put("mall_orgou", "zongji");
142        map.put("orgName", "总计");
143        map.put("amount", "0");
144        map.put("sellNum", "0");
145        map.put("saveamount", "0");
146        map.put("prdUpNum", "0");
147        map.put("OrderNum", "0");
148        map.put("aver", "0");
149        return map;
150    }
151    /**
152     * 判断字符串是否为电话号码
153     * String
154     * @param arg
155     * @return
156     * @antuor zhangyanbing
157     * Aug 22, 2014
158     */
159    public static boolean isTel(String arg){
160        String matches= "(^[0-9]{11,12}$)";
161        boolean result = false;
162        if(arg != null && !"".equals(arg)){
163            result = Pattern.matches(matches,arg);
164        }
165        return result;
166    }
167     
168     
169    /**
170     * 判断字符串是否为条形码(判断是否为13位正整数)
171     * String
172     * @param arg
173     * @return
174     * @antuor shaozj
175     * 2014-9-22 14:51:38
176     */
177    public static boolean isBarCode(String arg){
178        String matches= "(^[0-9]{13}$)";
179        boolean result = false;
180        if(arg != null && !"".equals(arg)){
181            result = Pattern.matches(matches,arg);
182        }
183        return result;     
184    }
185    public static String arrayToString(String[] strArry,String exp){
186        StringBuilder str = null;
187        str = new StringBuilder();
188        for (int i = 0; i < strArry.length; i++) {
189            String s = strArry[i];
190            str.append(s);
191            if(i!=strArry.length-1){
192                str.append(exp);
193            }
194        }
195        return str.toString();
196    }
197     
198    /**
199     * 异常信息toString
200     *
201     * @param ex
202     * @return
203     */
204    public static String getExceString(Exception ex){
205        StackTraceElement [] arry_ex = ex.getStackTrace();
206        String temp = ex.toString();
207        for(int i=0;i<arry_ex.length;i++){
208            temp += "\n"+arry_ex[i].toString();
209        }
210        System.out.println(temp);
211        return temp;
212    }
213}
最近下载更多
13940562934  LV22 2023年9月27日
amour1  LV11 2021年12月3日
ewan007  LV30 2021年1月27日
a991206  LV10 2021年1月5日
桃花人  LV6 2020年12月17日
IT白夜  LV12 2020年12月17日
1900110734  LV6 2020年12月4日
240598911  LV10 2020年11月25日
怎么取名字啊14  LV4 2020年9月27日
hjh844615  LV6 2020年9月20日
最近浏览更多
999772 5月7日
暂无贡献等级
vincemokea  LV5 4月30日
f22m1a2b2  LV17 1月23日
zhoubowen  LV3 2024年12月29日
Ella0902 2024年12月18日
暂无贡献等级
xzg123456  LV6 2024年6月18日
h G24741  LV2 2024年3月12日
KIKO666 2024年2月21日
暂无贡献等级
沈从文  LV3 2024年1月1日
uni-code_0123  LV1 2023年11月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友