This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、客户端发出请求; | |
2、DispatcherServlet 获取请求; | |
3、DispatcherServlet 查询 HandlerMapping,将请求的URL映射到一个控制器对象Controller, | |
并将请求分发给这个 Controller; | |
4、Controller 根据设计的业务逻辑处理请求; | |
5、完成业务逻辑的处理后,Controller 返回一个ModelAndView 给 DispatcherServlet ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/index.html = anon | |
/user/create = anon | |
/user/** = authc | |
/admin/** = authc, roles[administrator] | |
/rest/** = authc, rest | |
/remoting/rpc/** = authc, perms["remote:invoke"] | |
过滤器名称 过滤器类 描述 | |
anon org.apache.shiro.web.filter.authc.AnonymousFilter 匿名过滤器 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpClient client = null; | |
try { | |
client = new DefaultHttpClient();//获得一个代理 | |
HttpGet get = new HttpGet("http://www.youdao.com/smartresult-xml/search.s?type=id&q="+code);//获得请求 | |
HttpResponse response = client.execute(get);//获得响应 | |
InputStream stream = response.getEntity().getContent(); //从内存角度,获得一个输入流 | |
BufferedReader reader = new BufferedReader(new InputStreamReader(stream,"GBK")); | |
//获得的文字,以字符流的形式输出【图片、MP3,文件用字节流输出】 | |
StringBuilder sb = new StringBuilder(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createXMLHttpRequest(){ | |
var xmlHttp;//创建ajax引擎 | |
if(window.ActiveXObject){ | |
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); | |
}else{ | |
xmlHttp = new XMLHttpRequest(); | |
} | |
return xmlHttp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//让session过期 | |
request.getSession().invalidate();//安全退出,强制Session过期 | |
//删除cookie | |
Cookie[] cookies = request.getCookies(); | |
if(cookies!=null){ | |
for(Cookie c:cookies){ | |
if("username".equals(c.getName())||"password".equals(c.getName())){ | |
c.setMaxAge(0); | |
c.setPath("/"); | |
c.setDomain("www.wdfx100.com"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
login.java: | |
if(rm != null){ | |
Cookie usernameCookie =new Cookie("username", username); | |
usernameCookie.setDomain("www.wdfx100.com"); | |
usernameCookie.setPath("/"); | |
usernameCookie.setMaxAge(60*60*24); | |
Cookie passwordCookie =new Cookie("password", password); | |
passwordCookie.setDomain("www.wdfx100.com"); | |
passwordCookie.setPath("/"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jar | |
commons-codec-1.6.jar | |
sha.js | |
<form action="login" method="post" class="formgo"> | |
<c:choose> | |
<c:when test="${param.error=='1001' }"> | |
<p>用户名或密码错误 </p> | |
</c:when> |
NewerOlder