- 浏览: 292577 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
springdata_springmvc:
java程序语言学习教程 地址http://www.zuida ...
JAVA获取CLASSPATH路径 -
springdata-jpa:
可以参考最新的文档:如何在eclipse jee中检出项目并转 ...
Maven2创建项目 -
程序员是怎么炼成的:
嗯 , 谢谢!
JAVA获取CLASSPATH路径 -
svygh123:
写的非常好,我已经连接通过,谢谢分享
Oracle建立DBLINK的详细步骤记录 -
aa00aa00:
恩,看了主人的博客,不错,我也是用的DBLINK,进行orac ...
Oracle建立DBLINK的详细步骤记录
收藏列表
- 全部 [120]
- python [6]
- javascript [7]
- freemarker [2]
- jquery [7]
- firefox [1]
- linux [2]
- java [18]
- oracle [4]
- webservice [3]
- sqlserver [3]
- html [3]
- other [3]
- powerdesigner [1]
- maven [1]
- spring mvc [26]
- 保险 [2]
- vba [11]
- lhgdialog [1]
- jeasyui [11]
- docker [1]
- require.js [1]
- gooflow [3]
- jsplumb [1]
- emberjs [1]
- mvel2 [1]
- rancher [1]
标题 | 标签 | 来源 | |
docker command | docker | ||
aliyun:(41) username:88755A9DAE90A79411AC password:jzCfVGGxdsJSm9FgZLraQKgudUsDGuJBf2Mo36GM qcloud: Access Key(username):D65E56D202EDC2878517 Secret Key (Password):EbwheG45apJ5uJG2qGp7ZXJCkprKQE6v2yo3rKqj appSoar:(local) Access Key(username):805CF75CA4D40DF11B51 Secret Key (Password):PAzojsfLWZ8pWP4rHvgSnMcKSEEyGN6UAaYeto1Y yum install update yum install unzip docker load -i rancher-server-v101.tar docker images docker run -d --name rancher-aliyun-v101 -p 8080:8080 rancher/server:v1.0.1 docker run -d -p 5000:5000 --restart=always registry:2 docker tag 192.168.180.205:5000/redis 192.168.5.41:5000/redis docker push 192.168.5.41:5000/redis vi /lib/systemd/system/docker.service systemctl daemon-reload systemctl restart docker docker ps docker ps -l 125 docker create --name=rancher-data --volumes-from rancher-aliyun-v101 126 docker create --name=rancher-data --volumes-from rancher-aliyun-v101 rancher/server:v1.0.1 127 docker ps -a 128 docker rm racher-aliyun-v101 129 docker rm rancher-aliyun-v101 130 docker ps -a 131 history | grep rancher-ali 132 docker run -d --name=rancher-aliyun-v101 -p 8080:8080 --restart=always --volumes-from=rancher-data rancher/server:v1.0.1 133 docker ps 134 docker push 192.168.5.41:5000/redis 135 ps -aux 136 ps -aux| grep daemon docker create --name=rancher-qcloud-data -v /data/qcloud rancher/server:v1.0.1 docker tag 192.168.180.205:5000/python-redis-demo:b77 192.168.5.41:5000/python-redis-demo:b77 docker节点: rancher-compose --url http://192.168.5.41:8080 --access-key 88755A9DAE90A79411AC --secret-key jzCfVGGxdsJSm9FgZLraQKgudUsDGuJBf2Mo36GM --file ./docker-compose.yml --rancher-file ./rancher-compose.yml -p aliyun-stack1 up rancher-compose --url http://192.168.5.41:8090 --access-key D65E56D202EDC2878517 --secret-key EbwheG45apJ5uJG2qGp7ZXJCkprKQE6v2yo3rKqj --file ./docker-compose.yml --rancher-file ./rancher-compose.yml -p qcloud-stack1 up 1. 为运行容器的虚拟机增加一个虚拟磁盘,如 200GB大小 2. pvcreate /dev/sdb 3. vgcreate docker_data /dev/sdb 4. lvcreate –L 200g –T docker_data/thinpool 5. 修改:/lib/systemd/system/docker.service ExecStart=/usr/bin/docker daemon -H fd:// --storage-opt dm.thinpooldev=/dev/mapper/docker_data-thinpool --insecure-registry 192.168.5.41:5000 6. 更新docker配置:systemctl daemon-reload 7. cd /var/lib 8. rm -rf docker/ 9. 重启docker服务:systemctl restart docker 10. 修改计算机名:vi /etc/hostname docker run -d --name=rancher-qcloud-v101 -p 8090:8080 --restart=always --volumes-from=rancher-qcloud-data rancher/server:v1.0.1 docker run -d --name=rancher-qcloud-v101 -p 8090:8080 --restart=always rancher/server:v1.0.1 Activating (Waiting for [instance:stack-1463571012354_pyapplb_1]. Instance status: Scheduling failed: host needs ports 5077/tcp available) https://DESKTOP-CFOER2H:444/svn/appstore rancher-compose --url http://192.168.5.41:8080 --access-key 88755A9DAE90A79411AC --secret-key jzCfVGGxdsJSm9FgZLraQKgudUsDGuJBf2Mo36GM --file /root/rancher-compose/stack-20160713110822479625/docker-compose.yml --rancher-file /root/rancher-compose/stack-20160713110822479625/rancher-compose.yml -p stack-20160713110822479626 up -d |
|||
git.clone.sh | linux | ||
[root@broker git]# cat git.clone.sh #!/bin/bash if [ ! -n $1 ]; then echo "error, please input project name." elif [[ $1 = "" ]]; then echo "error, please input project name." else git config --global user.name "root" git config --global user.email "hong.pan@cloudsoar.com" git clone http://192.168.5.41/root/$1.git cd $1 # 替换文件中的指定内容 filepath="./.git/config" sed -i '7 s/192.168.5.41/root:Aa123456@192.168.5.41/g' $filepath touch README.md git add README.md git commit -m "add README" git push -u origin master fi |
|||
【rancher】 | rancher | ||
curl -H "Accept:application/json" http://rancher-metadata |
|||
【emberjs】 | emberjs | ||
http://emberjs.com/ |
|||
java常用收集 | java | ||
WindowBuilder: http://www.eclipse.org/windowbuilder/download.php |
|||
【axis1.4】maven依赖及WSDL2Java.bat | webservice | Maven dependencies for web service client using axis1 | |
/* http://stackoverflow.com/questions/6368862/maven-dependencies-for-web-service-client-using-axis1 maven 依赖: <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis-jaxrpc</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.2</version> </dependency> WSDL2Java.bat set AXIS_HOME=D:\ebook\axis\axis-1_4 set CLASSPATH=,;%AXIS_HOME%\lib\axis.jar;%AXIS_HOME%\lib\axis-ant.jar;%AXIS_HOME%\lib\commons-discovery-0.2.jar;%AXIS_HOME%\lib\commons-logging-1.0.4.jar;%AXIS_HOME%\lib\jaxrpc.jar;%AXIS_HOME%\lib\log4j-1.2.8.jar;%AXIS_HOME%\lib\saaj.jar;%AXIS_HOME%\lib\wsdl4j-1.5.1.jar;%AXIS_HOME%\lib\mail.jar; REM wsdl2java -encoding UTF-8 -p com.cignacmb.rcc.wsclient.icis http://10.142.142.10:9080/iCIS/services/WebServiceServer?WSDL REM java org.apache.axis.wsdl.WSDL2Java -p http://10.142.142.10:9080/iCIS/services/WebServiceServer?WSDL java org.apache.axis.wsdl.WSDL2Java -p com.cignacmb.rcc.wsclient.icis http://10.142.142.10:9080/iCIS/services/WebServiceServer?WSDL */ |
|||
【python】doc | python | ||
Python 中文官方文档 http://python.usyiyi.cn/ |
|||
【python】cx_Oracle | python | Welcome to cx_Oracle’s documentation! | |
python常用安装 | python | ||
https://pip.pypa.io/en/stable/installing/ python -m pip install -U pip https://pip.pypa.io/en/stable/installing/#upgrading-pip pip.exe install cx_Oracle python 2.7 Windows下pip安装包报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat http://www.cnblogs.com/ldm1989/p/4210743.html Micorsoft Visual C++ Compiler for Python 2.7:https://www.microsoft.com/en-us/download/details.aspx?id=44266 python 3.4 要求是Microsoft Visual C++ 10.0 |
|||
【networkx】安装 | python | ||
https://pypi.python.org/pypi/networkx/ networkx使用笔记(一)之安装篇 http://blog.csdn.net/moodytong/article/details/7282008 python下的复杂网络编程包networkx的使用(摘抄) http://blog.sina.com.cn/s/blog_720448d301018px7.html 用 python绘图及网络分析(win64下matplotlib,networkx安装方法) http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=13246637&id=4654827 1. matplotlib-1.4.2.win-amd64-py2.7.exe 2. numpy-MKL-1.9.1.win-amd64-py2.7.exe 3. pyparsing-2.0.3.win-amd64-py2.7.exe 4. python-dateutil-2.2.win-amd64-py2.7.exe 5. scipy-0.14.0.win-amd64-py2.7.exe 6. six-1.8.0.win-amd64-py2.7.exe https://www.douban.com/note/484046487/ 下载.whl包 先pip install wheel 之后pip install 包名字.whl 即可安装某模块包 一般第三方的组件都是以egg文件的方式存在的,安装egg文件需要先安装setuptools工具,下载地址:https://pypi.python.org/pypi/setuptools/,下载完成后双击msvc-build-launcher编译即可。 查看安装是否成功:在你的Python安装路径下(我的是C:\\Python27)进入Scripts文件夹,查看是否有easy_install.exe文件,有就安装成功了! 安装egg文件时,打开CMD,依次键入: cd \d c:\Python27\Scripts easy_install zope.interface-4.1.2-py2.7-win32.egg |
|||
collection | other | ||
https://code.angularjs.org/ 上网账号:075507057476@163.gd 密码:KMIQDQVG 维修电话:张 18025399861 github: dkawskawx123 中国高等教育学生信息网(学信网):http://www.chsi.com.cn/ 15012838169/dkawskawx123pan 《教育部学历证书电子注册备案表》 深圳人才网:http://www.szhr.com.cn/diplomachk/index.shtml 深圳市人才交流服务中心人才征信部 电话:0755-82122347 传真:0755-82122400 地址:深圳市宝安北路人才大市场大厦六楼668室人才征信部 邮编:518023 天津市人才服务中心:http://www.tjtalents.com.cn/ 人事档案:022-28013666 http://sz.bendibao.com/life/2007116/52435.htm 天津市人民政府驻深办事处 地址:春风路锦星花园6栋2单元 电话:25104127 25104126 传真:25104128 深圳市.人力资源和.社会保障局 http://www.szhrss.gov.cn/ 广东省网上办事大厅 深圳市人力资源和社会保障局窗口 https://sz12333.gov.cn/rcyj/ drolly/Aa123456 社会保险服务个人网页 https://e.szsi.gov.cn/siservice/ oracle:cheney0502@gmail.com / dkawskawx123PH http://www.oracle.com/index.html 输入并确认数据库的口令。此口令将用于SYS和SYSTEM数据库账户。口令:Aa123456 目标文件夹: C:\oraclexe\ Oracle 主目录: C:\oraclexe\app\oracle\product\11.2.0\server\ Oracle 基目录:C:\oraclexe\ 'Oracle 数据库监听程序' 的端口: 1521 'Oracle Services for Microsoft Transaction Server' 的端口: 2030 'Oracle HTTP 监听程序' 的端口: 8080 vnc: Sc-201412022040 / 123456 DESKTOP-0UG2QM0 / 123456 《互联网思维2.0:传统企业互联网转型》 《理性的繁荣》 《祈祷落幕时》 《一无所有,就是拼的理由》 《高效能人士的七个习惯》 《男人来自火星,女人来自金星》 《爱的五种语言》 《时间悖论》 《生命中不该忘记的事》 《批判性思维》 《沟通的艺术》 《学会提问》 《长尾理论》 《免费》 《领导力十律》 《你的生命有什么可能》 《世界是自己的,与他人无关》 《折掉思维里的墙》 《你只是看起来很努力》 《管理十律》 小金理财:https://www.xiaojinlicai.com/home 星月创投:http://www.zgxyct.com/mypage.page app id: 没有喜欢的 阳光保险 重庆市 |
|||
ImportError: No module named images | python | ImportError: No module named images | |
ImportError: No module named images 替换为 import wx.py.images as images 将 images.getNewBitmap 替换为 images.getPyBitmap() |
|||
You are using pip version 8.0.2, however version 8.0.3 is available. | python | Python升级pip到更高版本 You are using pip version 7.0.3, however version 7.1.0 is available. | |
进入到easy_install的目录 例如D:\Python27\Scripts 通过指令 easy_install.exe pip==8.0.3 最后安装成功。 出现的问题: C:\Python27\Scripts>pip.exe install image Collecting images Could not find a version that satisfies the requirement images (from versions: ) No matching distribution found for images You are using pip version 8.0.2, however version 8.0.3 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. 通过以下升级: C:\Python27\Scripts>easy_install.exe pip==8.0.3 再执行进行安装: C:\Python27\Scripts>pip.exe install image |
|||
获取本机ip等信息 | java | ||
InetAddress ia = null; ia = InetAddress.getLocalHost(); String localname = ia.getHostName(); String localip = ia.getHostAddress(); System.out.println("本机名称是:" + localname); System.out.println("本机的ip是 :" + localip); |
|||
【POI】excel操作 | java | ||
/* maven 依赖: <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.11</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.11</version> </dependency> http://lxneliu.iteye.com/blog/1614148 http://my.oschina.net/zhanglikun/blog/130147 */ |
|||
lvyou | other | ||
求水山公园 http://www.dianping.com/shop/4033600 龙岗区 布吉镇南岭村(近南岭花园) 地王观光 荔枝公园 深圳中心公园 |
|||
Firefox 附加组件 | firefox | ||
HACKBAR:https://addons.mozilla.org/zh-CN/firefox/addon/hackbar/ |
|||
CCAF | other | ||
dependency FastJson:http://fastjson.codeplex.com/ maven maven-site-plugin maven-javadoc-plugin <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>3.3</version> <configuration> <locales>zh_CN</locales> <outputEncoding>GBK</outputEncoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.8.1</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> |
|||
【MVEL2】基本操作示例 | mvel2 | ||
/** <dependency> <groupId>org.mvel</groupId> <artifactId>mvel2</artifactId> <version>2.2.4.Final</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.3.2</version> </dependency> */ public class Mvel2Test extends TestCase { /** * 基本语法 */ public void testAttr() { Mvel2TestModel model = new Mvel2TestModel(); // 可用于通用设置 MVEL.setProperty(model, "name", "test"); System.out.println(MVEL.getProperty("name", model)); // 简单的属性表单式 Object result = MVEL.eval("name", model); System.out.println("result = " + result); System.out.println("====================================="); // 布尔表达式 result = MVEL.eval("name=='test'", model); System.out.println("result = " + result); } public void testCommond(){ Mvel2TestModel model = new Mvel2TestModel(); Map<String, Object> map = new HashMap<String, Object>(); String exp1 = this.getCommond("t1.txt"); Serializable compiled = MVEL.compileExpression(exp1); long startTime = System.currentTimeMillis(); // http://markmail.org/message/mrcmjngtkfzmw4ak // 脚本中有赋值动作时,需设置map参数 // map中的key值可约定为: // 1. 以约定名开头,如:MODELATTR_,以表示此key有对应的属性; // 2. 其他部分为模型中的属性名,以下划线"_"分割层级,方便还原赋值; Object result = MVEL.executeExpression(compiled, model, map); System.out.println("耗时:" + (System.currentTimeMillis() - startTime)); System.out.println("result = " + result); System.out.println("Name = " + model.getName()); this.displayMap(map); } /** * 根据身份证号提取出生日和性别 */ public void testIDNO() { Mvel2TestModel model = new Mvel2TestModel(); model.setName("钟新飞"); model.setIdtype("1"); // 1-身份证号 model.setIdno("513325198304191153"); Map<String, Object> map = new HashMap<String, Object>(); String exp1 = this.getCommond("idno.txt"); Serializable compiled = MVEL.compileExpression(exp1); long startTime = System.currentTimeMillis(); Object result = MVEL.executeExpression(compiled, model, map); System.out.println("耗时:" + (System.currentTimeMillis() - startTime)); System.out.println("result = " + result); this.displayMap(map); } private String getCommond(String file) { InputStream is = this.getClass().getResourceAsStream(file); try { return IOUtils.toString(is); } catch (IOException e) { e.printStackTrace(); } return null; } private void displayMap(Map<String, Object> map){ System.out.println("======== map: "); if (null == map) { System.out.println("It's null."); } else { Set<Entry<String, Object>> set = map.entrySet(); for (Entry<String, Object> entry : set) { System.out.println("key/value = " + entry.getKey() + "/" + entry.getValue()); } } } } public class Mvel2TestModel implements Serializable { private String name; private String idtype; private String idno; private String sex; private Date birthday; private int value = 1; } /** t1.txt if(value > 0){ System.out.println("Greater than zero!"); } else if(value == -1){ System.out.println("Minus one!"); } else { System.out.println("Something else!"); } String name1 = "String 1"; String name2 = "String 2"; -------------------------------------------------------------------------- idno.txt /** 15位身份证号: 前6位 中间6位 后三位 地区代码 生日:年月日 奇为男,偶为女 18位身份证号码各位数字的含义如下: (1)前1、2位数字表示:所在省份的代码; (2)第3、4位数字表示:所在城市的代码; (3)第5、6位数字表示:所在区县的代码; (4)第7~14位数字表示:出生年、月、日; (5)第15、16位数字表示:所在地的派出所的代码; (6)第17位数字表示性别:奇数表示男性,偶数表示女性; (7)第18位数字是校检码:也有的说是个人信息码,一般是随计算机的随机产生, 用来检验身份证的正确性。校检码可以是0~9的数字,有时也用x表示。 */ import org.apache.commons.lang3.time.DateUtils; String birthday = ""; String sex = "M"; // M-男;F-女 if(idtype == "1") { if(idno.length() == 15) { birthday = DateUtils.parseDate("19" + idno.substring(6, 12), "yyyyMMdd"); sex = Integer.valueOf(idno[14]).intValue() % 2 == 0 ? "F" : "M"; } else if(idno.length() == 18){ // birthday = idno.substring(6, 14); birthday = DateUtils.parseDate(idno.substring(6, 14), "yyyyMMdd"); sex = Integer.valueOf(idno[16]).intValue() % 2 == 0 ? "F" : "M"; } } */ |
|||
【zxing】条形码、二维码 | java | ||
/** <dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>3.2.1</version> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>3.2.1</version> </dependency> */ /** * http://www.cnblogs.com/hongten/archive/2012/10/26/java_qrcode.html * http://blog.csdn.net/yiluoak_47/article/details/22808915 * @author cheney */ public class QRCodeTest extends TestCase { private static final int BLACK = 0xff000000; private static final int WHITE = 0xFFFFFFFF; @Test public void testBarCode() { // bar code String imgPath = "e:/123.jpg"; String contents = "6943620593115"; int width = 105, height = 50; encodeBarCode(contents, width, height, imgPath); String decodeContent = decodeBarCode(imgPath); System.out.println("解码内容如下:"); System.out.println(decodeContent); } private void encodeBarCode(String contents, int width, int height, String imgPath) { int codeWidth = 3 + // start guard (7 * 6) + // left bars 5 + // middle guard (7 * 6) + // right bars 3; // end guard codeWidth = Math.max(codeWidth, width); try { BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.EAN_13, codeWidth, height, null); Path path = new File(imgPath).toPath(); MatrixToImageWriter.writeToPath(bitMatrix, "png", path); } catch (Exception e) { e.printStackTrace(); } } private String decodeBarCode(String imgPath) { BufferedImage image = null; Result result = null; try { image = ImageIO.read(new File(imgPath)); if (image == null) { System.out.println("the decode image may be not exit."); } LuminanceSource source = new BufferedImageLuminanceSource(image); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); result = new MultiFormatReader().decode(bitmap, null); return result.getText(); } catch (Exception e) { e.printStackTrace(); } return null; } @Test public void testQRCode() { // QRCode String content = "helloworld. Welcome to my zone:http://www.cnblogs.com/my"; File file = new File("e://test.png"); this.encodeQRCode(content, file, BarcodeFormat.QR_CODE, 200, 200, null); this.decodeQRCode(file); } /** * 生成QRCode二维码<br> * 在编码时需要将com.google.zxing.qrcode.encoder.Encoder.java中的<br> * static final String DEFAULT_BYTE_MODE_ENCODING = "ISO8859-1";<br> * 修改为UTF-8,否则中文编译后解析不了<br> */ private void encodeQRCode(String contents, File file, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) { try { BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, format, width, height); writeToFile(bitMatrix, "png", file); } catch (Exception e) { e.printStackTrace(); } } /** * 生成二维码图片<br> * * @param matrix * @param format * 图片格式 * @param file * 生成二维码图片位置 * @throws IOException */ private void writeToFile(BitMatrix matrix, String format, File file) throws IOException { BufferedImage image = toBufferedImage(matrix); ImageIO.write(image, format, file); } /** * 生成二维码内容<br> * @param matrix * @return */ private BufferedImage toBufferedImage(BitMatrix matrix) { int width = matrix.getWidth(); int height = matrix.getHeight(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { image.setRGB(x, y, matrix.get(x, y) == true ? BLACK : WHITE); } } return image; } /** * 解析QRCode二维码 */ @SuppressWarnings("unchecked") private void decodeQRCode(File file) { try { BufferedImage image; try { image = ImageIO.read(file); if (image == null) { System.out.println("Could not decode image"); } LuminanceSource source = new BufferedImageLuminanceSource(image); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer( source)); Result result; @SuppressWarnings("rawtypes") Hashtable hints = new Hashtable(); // 解码设置编码方式为:utf-8 hints.put(DecodeHintType.CHARACTER_SET, "utf-8"); result = new MultiFormatReader().decode(bitmap, hints); String resultStr = result.getText(); System.out.println("解析后内容:" + resultStr); } catch (IOException ioe) { System.out.println(ioe.toString()); } catch (ReaderException re) { System.out.println(re.toString()); } } catch (Exception ex) { System.out.println(ex.toString()); } } } |
|||
【FreeMarker】静态化 | freemarker | ||
/** * 示例 * @author cheney */ public class FreeMarkerTest extends AbstractJUnit4Test { @Resource private FreeMarkerConfigurer freemarkerConfig; @Test public void testProcess() throws IOException, TemplateException{ String templateName = "welcome.ftl"; Map<String, Object> map = new HashMap<String, Object>(); map.put("name", "cheney"); Configuration configuration = freemarkerConfig.getConfiguration(); Template template = configuration.getTemplate(templateName); File file = new File("e:/file.html"); Writer out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); template.process(map, out); org.apache.commons.io.IOUtils.closeQuietly(out); } } |
|||
【FreeMarker】spring mvc + freemarker(多个viewResolver) | freemarker, spring mvc | ||
/** <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.20</version> </dependency> applicationContext-mvc.xml http://blog.csdn.net/shandian534/article/details/5545219 ①order中的值越小,优先级越高。 ②而id为viewResolver的viewResolver的优先级是最低的。 <bean id="viewResolver_jsp" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> <property name="viewClass" value="com.cignacmb.liscont.web.controller.JSPJstlView" /> <property name="order" value="0" /> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="cache" value="true" /> <property name="prefix" value="" /> <property name="suffix" value=".ftl" /> <property name="contentType" value="text/html;charset=UTF-8"></property> <property name="requestContextAttribute" value="request" /> <property name="exposeSpringMacroHelpers" value="true" /> <property name="exposeRequestAttributes" value="true" /> <property name="exposeSessionAttributes" value="true" /> <property name="order" value="1" /> </bean> applicationContext.xml <!-- freemarker的配置 --> <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="classpath:ftl" /> <property name="defaultEncoding" value="utf-8" /> <property name="freemarkerSettings"> <props> <prop key="template_update_delay">10</prop> <prop key="locale">zh_CN</prop> <prop key="datetime_format">yyyy-MM-dd</prop> <prop key="date_format">yyyy-MM-dd</prop> <prop key="number_format">#.##</prop> </props> </property> </bean> */ @Controller @RequestMapping(value="/ftl") public class FreeMarkerController { @RequestMapping(value="/welcome.xhtml") public ModelAndView getFirstPage(HttpServletRequest request) { // welcom就是视图的名称(welcom.ftl) ModelAndView mv = new ModelAndView("welcome"); mv.addObject("name", "My First Spring Mvc"); return mv; } } /** <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body>Hello ${name} </body> </html> */ public class JSPJstlView extends JstlView { /** * http://www.iteye.com/problems/76107 * spring实现该方法时返回true,这样相当于view总是存在, * 从而导致其余视图解析器无法得到解析机会。 */ public boolean checkResource(Locale locale) throws Exception { File file = new File(this.getServletContext().getRealPath("/") + getUrl()); return file.exists();// 判断该jsp页面是否存在 } } |
|||
txt大文件读写 | java | ||
/** * */ package com.cignacmb.test.txt; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import junit.framework.TestCase; import org.junit.Test; /** * @author cheney * */ public class TxtUtilsTest extends TestCase{ private String filePath = "D:\\temp\\big-file-test.txt"; private String line = "通常,我们可以直接通过文件流来读取txt文件的内容,但有时可能会出现乱码!此时只要设置一下文件字符编码即可"; private long Times = 10000 * 1000; private String encoding = "UTF-8"; /** * testWrite testWriteByFileOutputStream * CPU: 占用很小,1~10% 占用很大,45% * 内存: 占用很大,可能上百M 占用很小,可能不到10M * 效率: 是10倍 很慢 * * 此方式性能可超过testWriteByFileOutputStream的10倍; * 如百万数据写及: * testWrite:1759 ms * testWriteByFileOutputStream: 23802 ms */ @Test public void testWrite() { this.checkFile(); long startTime = System.currentTimeMillis(); BufferedWriter fw = null; try { File file = new File(filePath); fw = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file, true), encoding)); // 指定编码格式,以免读取时中文字符异常 // fw.append("我写入的内容"); for (int i = 0; i < Times; i++) { fw.append(i + " >> "); fw.append(line); fw.newLine(); } fw.append("我又写入的内容"); fw.flush(); // 全部写入缓存中的内容 } catch (Exception e) { e.printStackTrace(); } finally { if (fw != null) { try { fw.close(); } catch (IOException e) { e.printStackTrace(); } } System.out.println("耗时:" + (System.currentTimeMillis() - startTime) + " ms"); } } @Test public void testWriteByFileOutputStream() { this.checkFile(); long startTime = System.currentTimeMillis(); FileOutputStream fos = null; try { fos = new FileOutputStream(filePath); for (int i = 0; i < Times; i++) { fos.write(new String(i + " >> ").getBytes(encoding)); fos.write(line.getBytes(encoding)); fos.write(new String("\r\n").getBytes(encoding)); } fos.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if(null != fos){ try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } System.out.println("耗时:" + (System.currentTimeMillis() - startTime) + " ms"); } } private void checkFile(){ File file1 = new File(filePath); if (file1.exists()) { file1.deleteOnExit(); } if (file1.exists() == false) { File parentFile = file1.getParentFile(); if (parentFile.exists() == false) { parentFile.mkdirs(); } } } @Test public void testReadByLine() { long startTime = System.currentTimeMillis(); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader( new FileInputStream(filePath), encoding)); // 指定读取文件的编码格式,要和写入的格式一致,以免出现中文乱码, String str = null; while ((str = reader.readLine()) != null) { // 日志输出很影响性能 System.out.println(str); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } System.out.println("耗时:" + (System.currentTimeMillis() - startTime) + " ms"); } } } |
|||
【spring mvc】复杂Form提交 | spring mvc | Spring3 mvc 复杂的Form提交 | |
public class FormBean { private String riskname; private String riskshortname; private List<Insured> list; } <tr> <td class="title"><label>险种中文名称</label></td> <td class="input"><input name="riskname" value="险种中文名称" class="easyui-textbox input-common"></td> <td class="title"><label>险种中文简称</label></td> <td class="input"><input name="riskshortname" value="险种中文简称" class="easyui-textbox input-common"></td> </tr> <tr> <td class="title"><label>被保险人一</label></td> <td class="input"><input name="list[0].insuredname" value="被保险人一" > </td> <td class="input"><input name="list[0].insuredidno" value="123123123" > </td> </tr> <tr> <td class="title"><label>被保险人二</label></td> <td class="input"><input name="list[1].insuredname" value="被保险人二" > </td> <td class="input"><input name="list[1].insuredidno" value="22312fds3" > </td> </tr> <script type="text/javascript"> $(document).ready(function(){ $("#multiParaTypeTestBtn").click(function(){ $("#multiParaTypeTest").form('submit', { url: '../tags/test.json', onSubmit: function(param){ return $(this).form('validate'); }, success: function(result){ var json = $.parseJSON(result); if(json.code == '0'){ $riskRelaTable.datagrid('reload'); $.messager.alert('提示','操作成功!','info'); } else { $.messager.alert('警告',json.message,'error'); } } }) }); }) </script> |
|||
【awk】统计日志文件中各IP出现次数 | linux | ||
awk '{a[$1]++}END{for(x in a)print x, a[x]}' test.log grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' test.log | awk '{a[$1]++}END{for(x in a)print x, a[x]}' # 用awk,sort,uniq统计日志小技巧 # http://blog.163.com/richma@126/blog/static/171357596201010193021619/ # 按统计量降序排列 grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' test.log | awk '{a[$1]++}END{for(x in a)print x, a[x]}' | sort -k 2 -rn 注:-k为排序关键列 -r为降序排序,sort默认的排序方式是升序 -n按算术值对数字字段排序。数字字段可包含前导空格、可选减号、十进制数字、千分位分隔符和可选基数符。对包含任何非数字字符的字段进行数字排序会出现无法预知的结果。 # 只得头10行 grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' test.log | awk '{a[$1]++}END{for(x in a)print x, a[x]}' | sort -k 2 -rn | head -n 10 # 只得后10行 grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' test.log | awk '{a[$1]++}END{for(x in a)print x, a[x]}' | sort -k 2 -rn | tail -n 10 |
|||
【jquery】jquery.lazyload图片分屏加载 | jquery | ||
wsimport | webservice | wsimport - Java™ API for XML Web Services (JAX-WS) 2.0 | |
# http://docs.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html -keep:是否生成java源文件 -d:指定输出目录 -s:指定源代码输出目录 -p:以package的形式生成文件 -verbose:在控制台显示输出信息 wsimport -keep -p com.cignacmb.member.center.wsclient.sms -verbose http://vmprsms01:9081/SMSPlatform/services/sendSMS?wsdl |
|||
js判断是http还是https | javascript | ||
<!-- CNZZ tracking code begin. --> <script type="text/javascript"> // unescape() 函数可对通过 escape() 编码的字符串进行解码。 var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://"); document.write(unescape("%3Cspan id='cnzz_stat_icon_1254736152'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/stat.php%3Fid%3D1254736152%26show%3Dpic' type='text/javascript'%3E%3C/script%3E")); </script> <!--CNZZ tracking code end. --> <!-- Gridsum tracking code begin. --> <script type='text/javascript'> (function () { var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = (location.protocol == 'https:' ? 'https://ssl.' : 'http://static.') + 'gridsumdissector.com/js/Clients/GWD-002432-09B92C/gs.js'; var firstScript = document.getElementsByTagName('script')[0]; firstScript.parentNode.insertBefore(s, firstScript); })(); </script> <!--Gridsum tracking code end. --> |
|||
【spring mvc】静态资源处理 | spring mvc | Spring MVC静态资源处理 | |
Spring MVC静态资源处理——<mvc:resources /> ||<mvc:default-servlet-handler /> 调整web.xml中的DispatcherServlet的配置,使其可以捕获所有的请求: <servlet> <servlet-name>springMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> 采用<mvc:default-servlet-handler /> ................... 采用<mvc:resources /> <mvc:default-servlet-handler />将静态资源的处理经由Spring MVC框架交回Web应用服务器处理。而<mvc:resources />更进一步,由Spring MVC框架自己处理静态资源,并添加一些有用的附加值功能。 首先,<mvc:resources />允许静态资源放在任何地方,如WEB-INF目录下、类路径下等,你甚至可以将JavaScript等静态文件打到JAR包中。通过location属性指定静态资源的位置,由于location属性是Resources类型,因此可以使用诸如"classpath:"等的资源前缀指定资源位置。传统Web容器的静态资源只能放在Web容器的根路径下,<mvc:resources />完全打破了这个限制。 其次,<mvc:resources />依据当前著名的Page Speed、YSlow等浏览器优化原则对静态资源提供优化。你可以通过cacheSeconds属性指定静态资源在浏览器端的缓存时间,一般可将该时间设置为一年,以充分利用浏览器端的缓存。在输出静态资源时,会根据配置设置好响应报文头的Expires 和 Cache-Control值。 在接收到静态资源的获取请求时,会检查请求头的Last-Modified值,如果静态资源没有发生变化,则直接返回303相应状态码,提示客户端使用浏览器缓存的数据,而非将静态资源的内容输出到客户端,以充分节省带宽,提高程序性能。 在springMVC-servlet中添加如下配置: <mvc:resources location="/,classpath:/META-INF/publicResources/" mapping="/resources/**"/> |
|||
【TAG】自定义标签与spring mvc | java | 自定义标签与spring注入 | |
maven 依赖 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> /** * 自定义标签基础类 * @author cheney */ public abstract class BaseTag extends RequestContextAwareTag { private static final long serialVersionUID = 1L; protected Logger logger = Logger.getLogger(getClass()); /** * 根据ID获取指定的spring bean * @param beanId * @return */ @SuppressWarnings("unchecked") protected <T> T getBean(String beanId) { WebApplicationContext context = this.getRequestContext() .getWebApplicationContext(); T bean = null; if (null != context && context.containsBean(beanId)) { bean = (T) context.getBean(beanId); } return bean; } } public class PolicySeekTag extends BaseTag { private static final long serialVersionUID = 1L; @Override protected int doStartTagInternal() throws Exception { logger.info("session ID: " + pageContext.getSession().getId()); TagsService tagsService = super.getBean("tagsService"); tagsService.log(); JspWriter out = null; try { out = pageContext.getOut(); out.print("测试"); } catch (Exception e) { logger.error(e.getMessage(), e); } return EVAL_PAGE; // 表示处理完标签后继续执行以下的JSP网页 // return SKIP_PAGE; //表示不处理接下来的JSP网页 } } // 在Web-Inf创建标签库描述文件self.tld <?xml version="1.0" encoding="UTF-8"?> <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"> <tlib-version>1.0</tlib-version> <jsp-version>2.2</jsp-version> <short-name>self</short-name> <uri>/selftaglib</uri> <tag> <name>policySeek</name> <tag-class>com.cignacmb.liscont.tags.PolicySeekTag</tag-class> <body-content>empty</body-content> </tag> </taglib> // web.xml <jsp-config> <taglib> <taglib-uri>/selftaglib</taglib-uri> <taglib-location>/WEB-INF/self.tld</taglib-location> </taglib> </jsp-config> // jsp <%@ taglib uri="/selftaglib" prefix="self"%> <td><self:policySeek></self:policySeek></td> |