Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -8,13 +8,15 @@ package com.xwbing.demo;
|
||||
*/
|
||||
public class Ademo {
|
||||
public static void main(String[] args) {
|
||||
qq:
|
||||
for(int i=0;i<10;i++) {
|
||||
for(int j=0;j<10;j++) {
|
||||
if(j == 5) break qq;
|
||||
}
|
||||
}
|
||||
System.out.println("11"=="11");
|
||||
System.out.println("11".equalsIgnoreCase(new String("11")));
|
||||
String a="aaaaa";
|
||||
String b="bbbbb";
|
||||
String aa = aa(a);
|
||||
System.out.println(aa);
|
||||
|
||||
}
|
||||
public static String aa(String aa){
|
||||
aa="aa";
|
||||
return aa;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,11 +50,11 @@ public class LambdaDemo {
|
||||
System.out.println("重用filter:" + lists.stream().filter(gt.and(lt)).collect(Collectors.toList()));
|
||||
//删除
|
||||
lists.removeIf(item -> item > 3);//根据条件删除,不用收集
|
||||
//聚合
|
||||
//聚合(最好给默认值,不然如果list为空时,聚合计算时会报错)
|
||||
System.out.println("reduce:" + lists.stream().reduce((o1, o2) -> o1 + o2).get());//聚合
|
||||
System.out.println("reduce:" + lists.stream().reduce(0, (o1, o2) -> o1 + o2));//聚合(给定默认值)
|
||||
System.out.println("ids:" + list.stream().reduce((sum, item) -> sum + "," + item).get());//常用//list(a,b,c)-->,a,b,c-->a,b,c
|
||||
System.out.println("ids:" + list.stream().reduce("", (sum, item) -> sum + "," + item).substring(1));
|
||||
System.out.println("ids:" + list.stream().reduce((sum, item) -> sum + "," + item).get());//list(a,b,c)-->,a,b,c
|
||||
System.out.println("ids:" + list.stream().reduce("", (sum, item) -> sum + "," + item).substring(1));//list(a,b,c)-->,a,b,c-->a,b,c
|
||||
String s = list.stream().reduce("", (sum, item) -> sum + "'" + item + "',");//list(a,b,c)-->'a','b','c',-->'a','b','c'
|
||||
System.out.println("id in:" + s.substring(0, s.lastIndexOf(",")));
|
||||
//join
|
||||
|
||||
@@ -8,9 +8,9 @@ import java.util.Map;
|
||||
* 说明: 公共数据类
|
||||
*/
|
||||
public class CommonDataUtil {
|
||||
private static Map<String, Object> token = new HashMap();
|
||||
private static Map<String, Object> token=new HashMap<>();
|
||||
|
||||
public CommonDataUtil() {
|
||||
private CommonDataUtil() {
|
||||
}
|
||||
|
||||
public static Object getToken(String key) {
|
||||
|
||||
@@ -15,8 +15,7 @@ import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* 说明: 创建验证码的servlet
|
||||
* 创建日期: 2016年8月29日 上午10:59:27
|
||||
* 作者: xiangwbd
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class CaptchaServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = -8687266469702749102L;
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.Random;
|
||||
|
||||
/**
|
||||
* 说明:验证码工具类
|
||||
* 创建日期: 2016年8月29日 上午10:57:41
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class CaptchaUtil {
|
||||
@@ -19,10 +18,10 @@ public class CaptchaUtil {
|
||||
private static final String FONT_NAME = "Fixedsys";
|
||||
private Random random = new Random();
|
||||
private static final int FONT_SIZE = 18;// 字体大小
|
||||
private static final int width = 80;// 图片宽
|
||||
private static final int height = 25;// 图片高
|
||||
private static final int lineNum = 50;// 干扰线数量
|
||||
private static final int strNum = 4;// 随机产生字符数量
|
||||
private static final int WIDTH = 80;// 图片宽
|
||||
private static final int HEIGHT = 25;// 图片高
|
||||
private static final int LINE_NUM = 50;// 干扰线数量
|
||||
private static final int STR_NUM = 4;// 随机产生字符数量
|
||||
|
||||
|
||||
/**
|
||||
@@ -30,23 +29,23 @@ public class CaptchaUtil {
|
||||
*/
|
||||
public BufferedImage genRandomCodeImage(StringBuffer randomCode) {
|
||||
// BufferedImage类是具有缓冲区的Image类
|
||||
BufferedImage image = new BufferedImage(width, height,
|
||||
BufferedImage image = new BufferedImage(WIDTH, HEIGHT,
|
||||
BufferedImage.TYPE_INT_BGR);
|
||||
// 获取Graphics对象,便于对图像进行各种绘制操作
|
||||
Graphics g = image.getGraphics();
|
||||
// 设置背景色
|
||||
g.setColor(getRandColor(200, 250));
|
||||
// 填充矩形面积
|
||||
g.fillRect(0, 0, width, height);
|
||||
g.fillRect(0, 0, WIDTH, HEIGHT);
|
||||
// 设置干扰线的颜色
|
||||
g.setColor(getRandColor(110, 120));
|
||||
// 绘制干扰线
|
||||
for (int i = 0; i <= lineNum; i++) {
|
||||
for (int i = 0; i <= LINE_NUM; i++) {
|
||||
drowLine(g);
|
||||
}
|
||||
// 绘制随机字符
|
||||
g.setFont(new Font(FONT_NAME, Font.ROMAN_BASELINE, FONT_SIZE));
|
||||
for (int i = 1; i <= strNum; i++) {
|
||||
g.setFont(new Font(FONT_NAME, Font.PLAIN, FONT_SIZE));
|
||||
for (int i = 1; i <= STR_NUM; i++) {
|
||||
randomCode.append(drowString(g, i));
|
||||
}
|
||||
g.dispose();
|
||||
@@ -86,8 +85,8 @@ public class CaptchaUtil {
|
||||
* 绘制干扰线
|
||||
*/
|
||||
private void drowLine(Graphics g) {
|
||||
int x = random.nextInt(width);
|
||||
int y = random.nextInt(height);
|
||||
int x = random.nextInt(WIDTH);
|
||||
int y = random.nextInt(HEIGHT);
|
||||
int x0 = random.nextInt(16);
|
||||
int y0 = random.nextInt(16);
|
||||
g.drawLine(x, y, x + x0, y + y0);
|
||||
@@ -104,7 +103,7 @@ public class CaptchaUtil {
|
||||
CaptchaUtil tool = new CaptchaUtil();
|
||||
StringBuffer code = new StringBuffer();
|
||||
BufferedImage image = tool.genRandomCodeImage(code);
|
||||
System.out.println(">>> random code =: " + code);
|
||||
System.out.println("random code : " + code);
|
||||
try {
|
||||
// 将内存中的图片通过流动形式输出到客户端
|
||||
ImageIO.write(image, "JPEG", new FileOutputStream(new File(
|
||||
|
||||
@@ -67,6 +67,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<!-- fileupload -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${fileUpLoad.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>boot-web</finalName>
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.servlet.Filter;
|
||||
//@ImportResource("classpath:applicationContext.xml")//用来加载其他xml配置文件
|
||||
public class ApplicationContextConfig {
|
||||
/**
|
||||
* encoding编码问题(springBoot默认已经配置好)
|
||||
* encoding编码问题(springBoot默认已经配置好,也可以在application.yml里配置)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -37,8 +37,9 @@
|
||||
<java.version>1.8</java.version>
|
||||
<fileUpLoad.version>1.3.1</fileUpLoad.version>
|
||||
<zxing.version>3.2.1</zxing.version>
|
||||
<fastjson.veersion>1.2.20</fastjson.veersion>
|
||||
<fastjson.version>1.2.20</fastjson.version>
|
||||
<rsa.version>1.45</rsa.version>
|
||||
<commons-io.version>2.2</commons-io.version>
|
||||
<!-- 打包跳过单元测试 -->
|
||||
<skipTests>true</skipTests>
|
||||
<swagger2.version>2.4.0</swagger2.version>
|
||||
@@ -68,7 +69,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.veersion}</version>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
@@ -93,9 +94,9 @@
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${fileUpLoad.version}</version>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
Reference in New Issue
Block a user