Skip to content

Instantly share code, notes, and snippets.

View wdfx100's full-sized avatar

wangxu wdfx100

View GitHub Profile
@wdfx100
wdfx100 / java
Created July 29, 2013 15:33
Spring MVC 处理请求流程
1、客户端发出请求;
2、DispatcherServlet 获取请求;
3、DispatcherServlet 查询 HandlerMapping,将请求的URL映射到一个控制器对象Controller,
并将请求分发给这个 Controller;
4、Controller 根据设计的业务逻辑处理请求;
5、完成业务逻辑的处理后,Controller 返回一个ModelAndView 给 DispatcherServlet ;
@wdfx100
wdfx100 / gist:6200582
Created August 10, 2013 14:10
根据正则表达式查找@的用户
Pattern p = Pattern.compile("@\\w+\\s");
String str = "@tom @jerry @rose 这是我的电子邮件,给我发邮件哦[email protected]";
Matcher m = p.matcher(str);
while(m.find()) {
System.out.println(m.group());
}
@wdfx100
wdfx100 / gist:6232463
Last active December 21, 2015 02:08
URL类
URL url = new URL("http://www.baidu.com");
URLConnection conn =url.openConnection();
InputStream stream = conn.getInputStream();
//字符流
BufferedReader reader = new BufferedReader(new InputStreamReader(stream,"UTF-8"));
String str = null;
StringBuffer sb = new StringBuffer();
while((str=reader.readLine())!=null){
sb.append(str);
@wdfx100
wdfx100 / gist:6232682
Created August 14, 2013 16:18
URL类的图片下载
URL url = new URL("http://www.kaishengit.com/images/2013.jpg");
URLConnection conn =url.openConnection();
InputStream stream = conn.getInputStream();
File file = new File("F:/tupian.jpg");
OutputStream out = new FileOutputStream(file);
BufferedInputStream bis = new BufferedInputStream(stream);
BufferedOutputStream bos = new BufferedOutputStream(out);