簫劍寒香
xiaojianhx · 共 45 篇文章
MyCat 读写分离
server.xml <?xml version="1.0" encoding="UTF-8"?> <!-- - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required …
2017-06-04 15:03 · 框架 · 评论(0)
vertx 获取请求参数
表单登录(GET) <form action="/login"> <input type="text" name="username"/> <input type="password" name="password"/> <input type="submit" /> </form> 使用下面的代码,获取请求的参数没问题: public class LoginHandler implements Handler<RoutingContext> { public void handle(RoutingContext rc) { String username = rc.request().ge…
2016-12-29 12:50 · vertx · 评论(0)
两个整数交换,不引入第三个参数
有两种方法: public class Test { public static void main(String[] args) { method1(); method2(); } private static void method1() { int a = Integer.MAX_VALUE; int b = Integer.MIN_VALUE; System.out.println("交换前" + a + "," + b); a = a + b; b = a - b; a = a - b; System.out.println("交换后" + a + "," + b); } priv…
2016-08-01 12:14 · JAVA · 评论(0)
for循环
如果作为面试题,可能很多人都会答错 public class Test { private static int count; public static void main(String[] args) { count = 0; for (int i : init()) {} System.out.println("foreach,init方法执行次数:" + count); count = 0; for (int i = 0; i < init().length; i++) {} System.out.println("for,init方法执行次数:" + count); } priva…
2016-08-01 11:10 · JAVA · 评论(0)
apache服务器
ab post测试 ab -n 1 -c 1 -p post.txt -T application/x-www-form-urlencoded http://localhost:8080/**/login.action
2016-07-12 16:09 · 服务 · 评论(0)
tomcat 常用配置
1.tomcat版本 apache-tomcat-9.0.0.M6 2.修改使用jdk版本(两步) 1)修改%TOMCAT_HOME%/bin/catalina.bat,增加 set JAVA_HOME=xxxx(指定jdk路径) 2)修改%TOMCAT_HOME%/bin/setclasspath.bat,增加 set JAVA_HOME=xxxx(指定jdk路径) 3.很多时候(尤其是提供接口API),并不希望调用方看到服务器信息,即隐藏http->header->server 1)修改%TOMCAT_HOME%/bin/server.xml,在Connector结点增加server属性…
2016-05-30 10:31 · 工具 · 评论(0)
linux常用操作、命令
每次都要去网上搜,整理下作为字典用吧 1.解压 tar zxvf xxxx.tar.gz ----解压到当前文件夹 tar zxvf xxxx.tar.gz -C /usr/local/bin/ ----解压到/usr/local/bin/ 2.移动文件/文件夹/重命名 mv src dst 3.复制 本地复制 cp src dst ----本地复制 远程复制 (远程 -> 本地) scp account@ip:远程路径 本地路径 ----复制文件 scp -r account@ip:远程路径 本地路径 ----复制文件夹 远程复制 (本地 -> 远程) scp 本地路径 account@i…
2016-05-21 10:50 · 操作系统 · 评论(0)
SpringMVC 返回json
1.依赖jar <properties> .... <springmvc.version>4.2.6.RELEASE</springmvc.version> <fasterxml.version>2.7.4</fasterxml.version> .... </properties> .... <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${springmvc.version}</version> </dependency> <depen…
2015-12-10 13:37 · SPRING · 评论(0)
JETTY支持JSP:JSP support not configured
使用jetty调试web应用,出现 JSP support not configured 的问题,原因是缺少依赖的jar jsp-2.1-jetty maven依赖如下: <properties> <jetty.version>6.1.26</jetty.version> </properties> <dependencies> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty</artifactId> <version>${jetty.version}</version> <scope>test</sco…
2015-11-19 12:32 · JAVA · 评论(0)
技巧:EDITPLUS配置JAVA环境
正确安装JDK; 正确安装EDITPLUS; 进入Tools->Preferences->Tools->User tools; 配置编译运行 Commond:D:\Program Files\Java\jdk1.7.0_45\bin\javac.exe Argument:$(FilePath) Initial directory:$(FileDir) Commond:D:\Program Files\Java\jdk1.7.0_45\bin\java.exe Argument:-cp $(FileDir)/ $(FileNameNoExt) Initial directory:$(FileD…
2013-12-03 23:33 · 技巧 · 评论(0)
jQuery dialog form 提交 后台不能取值的解决办法
1.众所周知,被jQuery dialog处理后,相应的模块是加到body上的,不在form里,提交form的时候,后台获取不到数据。 2.解决方法: 利用隐藏变量,即:在form里定义隐藏变量,dialog响应事件后,为隐藏变量赋值,这样form提交,可将隐藏变量带到后台。 3.例: <html> <head> <script type="text/javascript" src="jquery-ui-1.10.3.custom/js/jquery-1.9.1.js"></script> <script type="text/javascript" src="jquery-ui-1.10.…
2013-10-29 11:34 · JAVASCRIPT · 评论(0)
算法:牛生小牛
1.问题描述: 有一头牛,每年年初生一头小牛,每头小牛第四个年头每年年初也生一头小牛,按此规律,若无牛死亡,第N年有多少头牛? 2.表格分析: 3.程序解释: 用list存牛的信息,list的size就是牛的数量; 牛类,重要属性为age(年龄),根据年龄判断是否可以生育,如果可以,则创建新的牛类放入list中 4.代码: import java.util.ArrayList; import java.util.List; public class $ { private static List<Cow> data = new ArrayList<Cow>(); public static …
2013-10-25 00:43 · 算法 · 评论(0)
算法:矩阵
public class $ { public static void main(String[] args) { int size = 6; int[] arr = new int[size * size]; for (int i = 0; i < arr.length; i++) { arr[i] = i; } int[][] a = new int[size][size]; test(a, arr[0], size, 0); show(a); } private static void test(int[][] a, int rightUp, int size, int start) …
2013-09-26 22:21 · 算法 · 评论(0)
技巧:ArrayList删除元素时, 从尾部开始遍历,可大大提升执行效率
一.描述: 1. 工作中,常常遇到这样的要求: 将列表里符合(或不符合)某条件的元素删除, 如: 有列表list = [ "a", "b", "c", "d" ], 删除其中的"a", "b", "c" 2. 关键在于遍历: 建议从尾部开始, 取代常规的从头部开始 3. 有人会说 使用 LinkedList 更合适 -- 此处只考虑 ArrayList; 二.推断: 当 list 删除元素 "a" 之后, 变为 [ "b", "c", "d" ], 猜想, list 内部数组发生变化(内存的变化): list(1) --> list(0), list(2) --> list(1), list…
2012-12-13 15:12 · 技巧 · 评论(1)