<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[财富猪java站]]></title>
<link>http://www.caifuzhu.com.cn/</link>
<description><![CDATA[java学习站，让我们每天进步一点点！]]></description>
<language>zh-cn</language>
<copyright><![CDATA[Copyright 2005 PBlog2 v2.4]]></copyright>
<webMaster><![CDATA[zhouhaizhe@126.com(财富猪)]]></webMaster>
<generator>PBlog2 v2.4</generator> 
<image>
	<title>财富猪java站</title> 
	<url>http://www.caifuzhu.com.cn/images/logos.gif</url> 
	<link>http://www.caifuzhu.com.cn/</link> 
	<description>财富猪java站</description> 
</image>

			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=110</link>
			<title><![CDATA[看看我怎么为Java Web应用程序增加入侵检测功能 ]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[JavaScript]]></category>
			<pubDate>Mon,22 Mar 2010 15:52:28 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=110</guid>	
		<description><![CDATA[、Java Web简介 <br/>　　在Java Web应用程中，特别是网站开发中，我们有时候需要为应用程序增加一个入侵检测程序来防止恶意刷新的功能，防止非法用户不断的往Web应用中重复发送数据。当然，入侵检测可以用很多方法实现，包括软件、硬件防火墙，入侵检测的策略也很多。在这里我们主要介绍的是Java Web应用程序中通过软件的方式实现简单的入侵检测及防御。<br/><br/>　　该方法的实现原理很简单，就是用户访问Web系统时记录每个用户的信息，然后进行对照，并根据设定的策略（比如：1秒钟刷新页面10次）判断用户是否属于恶意刷新。<br/><br/>　　我们的入侵检测程序应该放到所有Java Web程序的执行前，也即若发现用户是恶意刷新就不再继续执行Java Web中的其它部分内容，否则就会失去了意义。这就需要以插件的方式把入侵检测的程序置入Java Web应用中，使得每次用户访问Java Web，都先要到这个入侵检测程序中报一次到，符合规则才能放行。<br/><br/>　　Java Web应用大致分为两种，一种纯JSP(+Java Bean)方式，一种是基于框架（如Struts、EasyJWeb等）的。第一种方式的Java Web可以通过Java Servlet中的Filter接口实现，也即实现一个Filter接口，在其doFilter方法中插入入侵检测程序，然后再web.xml中作简单的配置即可。在基于框架的Web应用中，由于所有应用都有一个入口，因此可以把入侵检测的程序直接插入框架入口引擎中，使框架本身支持入侵检测功能。当然,也可以通过实现Filter接口来实现。<br/><br/>　　在EasyJWeb框架中，已经置入了简单入侵检测的程序，因此，这里我们以EasyJWeb框架为例,介绍具体的实现方法及源码，完整的代码可以在EasyJWeb源码中找到。<br/><br/>　　在基于EasyJWeb的Java Web应用中，默认情况下你只要连续刷新页面次数过多，即会弹出如下的错误：<br/><br/>　　EasyJWeb框架友情提示!:-):<br/><br/>　　您对页面的刷新太快,请等待60秒后再刷新页面!<br/><br/>　　二、用户访问信息记录UserConnect.java类<br/><br/>　　这个类是一个简单的Java Bean，主要代表用户的信息，包括用户名、IP、第一次访问时间、最后登录时间、登录次数、用户状态等。全部<br/><br/>　　代码如下：<br/><br/>　　package com.easyjf.web;<br/><br/>　　import java.util.Date;<br/><br/>　　/**<br/><br/>　　*<br/><br/>　　*<br/><br/>　　Title:用户验证信息<br/><br/>　　*<br/><br/>　　Description:记录用户登录信息,判断用户登录情况<br/><br/>　　*<br/><br/>　　Copyright: Copyright (c) 2006<br/><br/>　　*<br/><br/>　　Company: <a href="http://www.easyjf.com/" target="_blank">http://www.easyjf.com/</a><br/><br/>　　* @author 蔡世友<br/><br/>　　* @version 1.0<br/><br/>　　*/<br/><br/>　　public class UserConnect {<br/><br/>　　private String userName;<br/><br/>　　private String ip;<br/><br/>　　private Date firstFailureTime;<br/><br/>　　private Date lastLoginTime;<br/><br/>　　private int failureTimes;//用户登录失败次数<br/><br/>　　private int status=0;//用户状态0表示正常,-1表示锁定<br/><br/>　　public int getFailureTimes() {<br/><br/>　　return failureTimes;<br/><br/>　　}<br/><br/>　　public void setFailureTimes(int failureTimes) {<br/><br/>　　this.failureTimes = failureTimes;<br/><br/>　　}<br/><br/>　　public Date getFirstFailureTime() {<br/><br/>　　return firstFailureTime;<br/><br/>　　}<br/><br/>　　public void setFirstFailureTime(Date firstFailureTime) {<br/><br/>　　this.firstFailureTime = firstFailureTime;<br/><br/>　　}<br/><br/>　　public String getIp() {<br/><br/>　　return ip;<br/><br/>　　}<br/><br/>　　public void setIp(String ip) {<br/><br/>　　this.ip = ip;<br/><br/>　　}<br/><br/>　　public Date getLastLoginTime() {<br/><br/>　　return lastLoginTime;<br/><br/>　　}<br/><br/>　　public void setLastLoginTime(Date lastLoginTime) {<br/><br/>　　this.lastLoginTime = lastLoginTime;<br/><br/>　　}<br/><br/>　　public String getUserName() {<br/><br/>　　return userName;<br/><br/>　　}<br/><br/> <br/><br/>public void setUserName(String userName) { <br/><br/>　　this.userName = userName;<br/><br/>　　}<br/><br/>　　public int getStatus() {<br/><br/>　　return status;<br/><br/>　　}<br/><br/>　　public void setStatus(int status) {<br/><br/>　　this.status = status;<br/><br/>　　}<br/><br/>　　}<br/><br/>　　三、监控线程UserConnectManage.java类<br/><br/>　　这是入侵检测的核心部分，主要实现具体的入侵检测、记录、判断用户信息、在线用户的刷新等功能，并提供其它应用程序使用本组件的调用接口。<br/><br/>　　package com.easyjf.web;<br/><br/>　　import java.util.Date;<br/><br/>　　import java.util.HashMap;<br/><br/>　　import java.util.HashSet;<br/><br/>　　import java.util.Iterator;<br/><br/>　　import java.util.Map;<br/><br/>　　import java.util.Set;<br/><br/>　　import o&#114;g.apache.log4j.Logger;<br/><br/>　　/**<br/><br/>　　*<br/><br/>　　*<br/><br/>　　Title:用户入侵检测信息<br/><br/>　　*<br/><br/>　　Description:用于判断用户刷新情况检查，默认为10秒钟之内连续连接10次为超时<br/><br/>　　*<br/><br/>　　Copyright: Copyright (c) 2006<br/><br/>　　*<br/><br/>　　Company: www.easyjf.com<br/><br/>　　* @author 蔡世友<br/><br/>　　* @version 1.0<br/><br/>　　*/<br/><br/>　　public class UserConnectManage {<br/><br/>　　private static final Logger logger = (Logger) Logger.getLogger(UserConnectManage.class.getName());<br/><br/>　　private static int maxFailureTimes=10;//最大登录失败次数<br/><br/>　　private static long maxFailureInterval=10000;//毫秒，达到最大登录次数且在这个时间范围内<br/><br/>　　private static long waitInterval=60000;//失败后接受连接的等待时间，默认1分钟<br/><br/>　　private static int maxOnlineUser=200;//同时在线的最大数<br/><br/>　　private final static Map users=new HashMap();//使用ip+userName为key存放用户登录信息UserLoginAuth<br/><br/>　　private static Thread checkThread=null;<br/><br/>　　private static class CheckTimeOut implements Runnable{<br/><br/>　　private Thread parentThread;<br/><br/>　　public&nbsp;&nbsp;CheckTimeOut(Thread parentThread)<br/><br/>　　{<br/><br/>　　this.parentThread=parentThread;<br/><br/>　　synchronized(this){<br/><br/>　　if(checkThread==null){<br/><br/>　　checkThread= new Thread(this);<br/><br/>　　//System.out.println( &#34;创建一个新线程！&#34;);<br/><br/>　　checkThread.start();<br/><br/>　　}<br/><br/>　　}<br/><br/>　　}<br/><br/>　　public void run() {<br/><br/>　　while(true)<br/><br/>　　{<br/><br/>　　if(parentThread.isAlive()){<br/><br/>　　try{<br/><br/>　　Thread.sleep(2000);<br/><br/>　　int i=0;<br/><br/>　　if(users.size() &gt;maxOnlineUser)//当达到最大用户数时清除<br/><br/>　　{<br/><br/>　　synchronized(users){//执行删除操作<br/><br/>　　Iterator it=users.keySet().iterator();<br/><br/>　　Set set=new HashSet();<br/><br/>　　Date now=new Date();<br/><br/>　　while(it.hasNext())<br/><br/>　　{<br/><br/>　　Object key=it.next();<br/><br/>　　UserConnect user=(UserConnect)users.get(key);<br/><br/>　　if(now.getTime()-user.getFirstFailureTime().getTime() &gt;maxFailureInterval)//删除超时的用户<br/><br/>　　{<br/><br/>　　set.add(key);<br/><br/>　　logger.info( &#34;删除了一个超时的连接&#34;+i);<br/><br/>　　i++;<br/><br/>　　}<br/><br/>　　}<br/><br/>if(i &lt;5)//如果删除少于5个，则强行删除1/2在线记录，牺牲性能的情况下保证内存 <br/><br/>　　{<br/><br/>　　int num=maxOnlineUser/2;<br/><br/>　　it=users.keySet().iterator();<br/><br/>　　while(it.hasNext() &amp;&amp; i{<br/><br/>　　set.add(it.next());<br/><br/>　　logger.info( &#34;删除了一个多余的连接&#34;+i);<br/><br/>　　i++;<br/><br/>　　}<br/><br/>　　}<br/><br/>　　users.keySet().removeAll(set);<br/><br/>　　}<br/><br/>　　}<br/><br/>　　}<br/><br/>　　catch(Exception e)<br/><br/>　　{<br/><br/>　　e.printStackTrace();<br/><br/>　　}<br/><br/>　　}<br/><br/>　　else<br/><br/>　　{<br/><br/>　　break;<br/><br/>　　}<br/><br/>　　}<br/><br/>　　logger.info( &#34;监视程序运行结束！&#34;);<br/><br/>　　}<br/><br/>　　}<br/><br/>　　//通过checkLoginValidate判断是否合法的登录连接，如果合法则继续，非法则执行<br/><br/>　　public static boolean checkLoginValidate(String ip,String userName)//只检查认证失败次数<br/><br/>　　{<br/><br/>　　boolean ret=true;<br/><br/>　　Date now=new Date();<br/><br/>　　String key=ip+ &#34;:&#34;+userName;<br/><br/>　　UserConnect auth=(UserConnect)users.get(key);<br/><br/>　　if(auth==null)//把用户当前的访问信息加入到users容器中<br/><br/>　　{<br/><br/>　　auth=new UserConnect();<br/><br/>　　auth.setIp(ip);<br/><br/>　　auth.setUserName(userName);<br/><br/>　　auth.setFailureTimes(0);<br/><br/>　　auth.setFirstFailureTime(now);<br/><br/>　　users.put(key,auth);<br/><br/>　　if(checkThread==null)new CheckTimeOut(Thread.currentThread());<br/><br/>　　}<br/><br/>　　else<br/><br/>　　{<br/><br/>　　if(auth.getFailureTimes() &gt;maxFailureTimes)<br/><br/>　　{<br/><br/>　　//如果在限定的时间间隔内，则返回拒绝用户连接的信息<br/><br/>　　if((now.getTime()-auth.getFirstFailureTime().getTime()) {<br/><br/>　　ret=false;<br/><br/>　　auth.setStatus(-1);<br/><br/>　　}<br/><br/>　　else&nbsp;&nbsp;if(auth.getStatus()==-1 &amp;&amp; (now.getTime()-auth.getFirstFailureTime().getTime()&lt;(maxFailureInterval+waitInterval)))//重置计数器<br/><br/>　　{<br/><br/>　　ret=false;<br/><br/>　　}<br/><br/>　　else<br/><br/>　　{<br/><br/>　　auth.setFailureTimes(0);<br/><br/>　　auth.setFirstFailureTime(now);<br/><br/>　　auth.setStatus(0);<br/><br/>　　}<br/><br/>　　}<br/><br/>　　//登录次数加1<br/><br/>　　auth.setFailureTimes(auth.getFailureTimes()+1);<br/><br/>　　}<br/><br/>　　//System.out.println(key+ &#34;:&#34;+auth.getFailureTimes()+&#34;:&#34;+ret+&#34;:&#34;+(now.getTime()-auth.getFirstFailureTime().getTime()));<br/><br/>　　return ret;<br/><br/>　　}<br/><br/> <br/><br/>public static void reset(String ip,String userName)//重置用户信息 <br/><br/>　　{<br/><br/>　　Date now=new Date();<br/><br/>　　String key=ip+ &#34;:&#34;+userName;<br/><br/>　　UserConnect auth=(UserConnect)users.get(key);<br/><br/>　　if(auth==null)//把用户当前的访问信息加入到users容器中<br/><br/>　　{<br/><br/>　　auth=new UserConnect();<br/><br/>　　auth.setIp(ip);<br/><br/>　　auth.setUserName(userName);<br/><br/>　　auth.setFailureTimes(0);<br/><br/>　　auth.setFirstFailureTime(now);<br/><br/>　　users.put(key,auth);<br/><br/>　　}<br/><br/>　　else<br/><br/>　　{<br/><br/>　　auth.setFailureTimes(0);<br/><br/>　　auth.setFirstFailureTime(now);<br/><br/>　　}<br/><br/>　　}<br/><br/>　　public static void remove(String ip,String userName)//删除用户在容器中的记录<br/><br/>　　{<br/><br/>　　String key=ip+ &#34;:&#34;+userName;<br/><br/>　　users.remove(key);<br/><br/>　　}<br/><br/>　　public static void clear()//清空容器中内容<br/><br/>　　{<br/><br/>　　if(!users.isEmpty())users.clear();<br/><br/>　　}<br/><br/>　　public static long getMaxFailureInterval() {<br/><br/>　　return maxFailureInterval;<br/><br/>　　}<br/><br/>　　public static void setMaxFailureInterval(long maxFailureInterval) {<br/><br/>　　UserConnectManage.maxFailureInterval = maxFailureInterval;<br/><br/>　　}<br/><br/>　　public static int getMaxFailureTimes() {<br/><br/>　　return maxFailureTimes;<br/><br/>　　}<br/><br/>　　public static void setMaxFailureTimes(int maxFailureTimes) {<br/><br/>　　UserConnectManage.maxFailureTimes = maxFailureTimes;<br/><br/>　　}<br/><br/>　　public static int getMaxOnlineUser() {<br/><br/>　　return maxOnlineUser;<br/><br/>　　}<br/><br/>　　public static void setMaxOnlineUser(int maxOnlineUser) {<br/><br/>　　UserConnectManage.maxOnlineUser = maxOnlineUser;<br/><br/>　　}<br/><br/>　　public static long getWaitInterval() {<br/><br/>　　return waitInterval;<br/><br/>　　}<br/><br/>　　public static void setWaitInterval(long waitInterval) {<br/><br/>　　UserConnectManage.waitInterval = waitInterval;<br/><br/>　　}<br/><br/>　　四、调用接口<br/><br/>　　在需要进入侵检测判断的地方，直接使用UserConnectManage类中的checkLoginValidate方法即可<br/><br/>如EasyJWeb的核心 Servletcom.easyjf.web.ActionServlet 中调用UserConnectManage的代码： <br/><br/>　　if(!UserConnectManage.checkLoginValidate(request.getRemoteAddr(),&#34;guest&#34;))<br/><br/>　　{<br/><br/>　　info(request,response,new Exception(&#34;您对页面的刷新太快,请等待&#34;+UserConnectManage.getWaitInterval()/1000+&#34;秒后再刷新页面！&#34;));<br/><br/>　　return;<br/><br/>　　}<br/><br/>　　五、总结<br/><br/>　　当然，这里提供的方法只是一个简单的实现示例，由于上面的用户信息是直接保存在内存中，若并发用户很大的时候的代码的占用，可以考虑引入数据库来记录用户的访问信息，当然相应的执行效率肯定用降低。上面介绍的实现中，入侵检测判断的策略也只有用户访问次数及时间间隔两个元素，您还可以根据你的实现情况增加其它的检测元素。<br/><br/>]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=109</link>
			<title><![CDATA[一个页面两个session的问题分析 ]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[JavaScript]]></category>
			<pubDate>Mon,22 Mar 2010 15:44:21 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=109</guid>	
		<description><![CDATA[本例为一个特例。<br/><br/> <br/><br/>背景：<br/><br/>Linux服务器，Apache+tomcat。Java Web工程文件放在webapps路径下。由于除了java工程外还有别的几个Web项目，使用Apache作为http服务器。Java工程采用SSH架构，用到extjs，flex等。<br/><br/>将某域名和Java工程目录绑定。 <br/><br/>有时会出现Flex页面无法获得session中数据的问题，而无论是开发调试过程中还是其它Windows服务器上均没有出现该问题。<br/><br/> <br/><br/>排查： <br/><br/>考虑到也许存在路径设置问题引起Windows和Linux下的不同。对于java代码的排查进行了一天，包括Session变量赋值，重置和取出，包括所有路径设置，没有发现任何问题。 使用HttpFox对页面Http信息进行抓取，发现在进入Flex页面时会得到两个jsessionid，被取的session不是原有session，自然不能获得session数据。<br/><br/>在另一台Linux机器上就安装tomcat，采用默认设置，没有任何问题，排除上面一条的猜测 。问题必然出现在Linux服务器上，并且应该是Http或Web服务器配置问题。<br/><br/>停掉Apache，直接使用tomcat的Web配置（注：此时的配置并没有将域名和webapps下的工程路径绑定，但当时还没有注意到这个问题），使用IP+路径名的方式访问Web页面。Flex页面变为只有一个session。<br/><br/>重新启用Apache，不进行域名绑定IP，一个session。<br/><br/>仅用域名绑定IP， 一个session；域名绑定IP+路径名，连个session！<br/><br/>到此，终于定位到连个session的配置条件，可是为什么会这样呢？<br/><br/> <br/><br/>此前，出现过这样的问题：即更改项目名称，则Flex页面不能正常进行数据通信。简单地进行源代码全文 查找，没有发现任何硬编码。此次再次尝试，发现仍然是这个问题，可是源文件里没有硬编码又是怎么回事呢？<br/><br/> 经过排查，发现进行数据通信的配置文件services-config.xml中，有设置路径context.root：<br/><br/>代码<br/>&lt;channel-definition id=&#34;my-amf&#34; class=&#34;mx.messaging.channels.AMFChannel&#34;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;endpoint url=&#34;<a href="http://" target="_blank">http://</a>{server.name}:{server.port}/{context.root}/spring/messagebroker/amf&#34; class=&#34;flex.messaging.endpoints.AMFEndpoint&#34;/&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/channel-definition&gt; <br/><br/>而该路径又是在FlexBuilder的配置中设的，其命令为：<br/><br/>-services &#34;services-config.xml&#34; -context-root &#34;HelloBlazeds&#34; <br/><br/>由于此前编译时context.root为一个固定的字符串，此后一直使用编译所得二进制文件。所以，当服务器使用域名绑定webapps下的项目名时，即——若访问URL中可以不需要加入项目路径名时，Flex执行时会因此多生成一个session，与之前session不同，于是原session中的数据无法被取到。<br/><br/> <br/><br/>解决方案： <br/><br/>去掉路径context.root，重编译Flex文件。若设置URL不需要加入项目名称时，使用这一套编译后的Flex二进制文件。（此方案目前暂时没有测试，本次更改为备份原以Skyeye为context.root的配置和编译后的文件。）<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=108</link>
			<title><![CDATA[Eclipse 中国日]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[JavaScript]]></category>
			<pubDate>Mon,22 Mar 2010 15:39:07 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=108</guid>	
		<description><![CDATA[很多人都用Eclipse开发Flash开发项目。据说之所以取这个名字是因为针对Sun公司的，貌似八卦了点…<br/><br/>2009年7月22日是一个比较特别的日子，对于用Eclipse开发的人来说，因为大家可以真正看到Eclipse了。哈哈，相信很多人都知道了，不知道的去看Wiki.<br/><br/>兄弟们可要早点起来，日食可是8点开始的。<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=107</link>
			<title><![CDATA[最新出炉2010暴强语录]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[java随写]]></category>
			<pubDate>Fri,05 Mar 2010 12:45:36 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=107</guid>	
		<description><![CDATA[1.知道你过得不好，我也就安心了。<br/><br/>2.这位帅哥，你好像我下一任男友<br/><br/>3.伯母你好，我是你儿子的男朋友<br/><br/>4.不要叫我宅女，请叫我居里夫人<br/><br/>5.真羡慕你这么年轻就认识我了。<br/><br/>6.最近总是失眠，16小时就醒一次。<br/><br/>7.人人都说我丑，其实我只是美得不明显。<br/><br/>8.别到处嚷嚷世界抛弃了你，世界原本就不是属于你<br/><br/>9.我们要向前看，不错过些歪瓜劣枣怎么知道什么是好<br/><br/>10.爱情是一杯酒 我小心翼翼捧给心爱的人 他不小心碰撒了 于是我兑上了水<br/><br/>11.生活不是林黛玉，不会因为忧伤而风情万种。<br/><br/>12.已经将整个青春都用来检讨青春，还要把整个生命都用来怀疑生命?<br/><br/>13.请转告王子,老娘还在披荆斩棘的路上,还有雪山未翻、大河未过、巨龙未杀、帅哥未泡……叫他继&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;续死睡吧!<br/><br/>14.人和猪的区别就是：猪一直是猪，而人有时却不是人<br/><br/>15.我爱你时，你说什么就是什么。 我不爱你时，你说你是什么。<br/><br/>16.你说...你喜欢我?其实...我一开始...其实我也...唉跟你说了吧,其实我也挺喜欢我自己的.<br/><br/>17.要不是打不过你，我早跟你翻脸了。<br/><br/>18.来世记得早点来娶我。<br/><br/>19.让我流泪的人，我一定会让你流血。<br/><br/>20.别轻易对别人说爱，别固执的将别人心门打开，又玩笑着离开。<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=106</link>
			<title><![CDATA[花生壳]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[web特效]]></category>
			<pubDate>Fri,26 Feb 2010 09:43:59 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=106</guid>	
		<description><![CDATA[&lt;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&#34;&gt;<br/>&lt;html xmlns=&#34;<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>&#34;&gt;<br/>&lt;head&gt;<br/>&lt;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&gt;<br/>&lt;title&gt;post 8010 test&lt;/title&gt;<br/>&lt;/head&gt;<br/>&lt;frameset rows=&#34;*&#34;&gt;<br/>&lt;frame name=&#34;main&#34; frameborder=&#34;no&#34; src=&#34;<a href="http://caifuzhu.com:8010" target="_blank">http://caifuzhu.com:8010</a>&#34;&gt;<br/>&lt;/frameset&gt;<br/>&lt;noframes&gt;&lt;body&gt;<br/>&lt;script type=&#34;text/javasctipt&#34;&gt;window.navigate(&#39;<a href="http://caifuzhu.com:8010" target="_blank">http://caifuzhu.com:8010</a>&#39;);&lt;/script&gt;<br/>&lt;/body&gt;<br/>&lt;/noframes&gt;&lt;/html&gt;<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=105</link>
			<title><![CDATA[javascipt 正则]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[JavaScript]]></category>
			<pubDate>Thu,25 Feb 2010 17:21:23 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=105</guid>	
		<description><![CDATA[1. Regular-e&#173;xpression literal characters Character Matches<br/>Alphanumeric character Itself<br/>\0 The NUL character (\u0000)<br/>\t Tab (\u0009)<br/>\n Newline (\u000A)<br/>\v Vertical tab (\u000B)<br/>\f Form feed (\u000C)<br/>\r Carriage return (\u000D)<br/>\xnn The Latin character specified by the hexadecimal number nn; for example, \x0A is the same as \n<br/>\uxxxx The Unicode character specified by the hexadecimal number xxxx; for example, \u0009 is the same as \t<br/>\cX The control character ^X; for example, \cJ is equivalent to the newline character \n<br/> <br/>2. Regular e&#173;xpression character classes Character Matches<br/><br/>[...] Any one character between the brackets.<br/>[^...] Any one character not between the brackets.<br/>.&nbsp;&nbsp;Any character except newline o&#114; another Unicode line terminator.<br/>\w Any ASCII word character. Equivalent to [a-zA-Z0-9_].<br/>\W Any character that is not an ASCII word character. Equivalent to [^a-zA-Z0-9_].<br/>\s Any Unicode whitespace character.<br/>\S Any character that is not Unicode whitespace. Note that \w and \S are not the same thing.<br/>\d Any ASCII digit. Equivalent to [0-9].<br/>\D Any character other than an ASCII digit. Equivalent to [^0-9].<br/>[\b] A literal backspace (special case).<br/> <br/>3. Regular e&#173;xpression repetition characters Character Meaning<br/>{n,m} Match the previous item at least n times but no more than m times.<br/>{n,} Match the previous item n o&#114; more times.<br/>{n} Match exactly n occurrences of the previous item.<br/>?&nbsp;&nbsp;Match zero o&#114; one occurrences of the previous item. That is, the previous item is optional. Equivalent to {0,1}.<br/>+ Match one o&#114; more occurrences of the previous item. Equivalent to {1,}.<br/>* Match zero o&#114; more occurrences of the previous item. Equivalent to {0,}.<br/> <br/>4。 Regular e&#173;xpression alt&#101;rnation, grouping, and reference characters Character Meaning<br/>| Alt&#101;rnation. Match either the sube&#173;xpression to the left o&#114; the sube&#173;xpression to the right.<br/>(...) Grouping. Group items into a single unit that can be used with *, +, ?, |, and so on. Also remember the characters that match this group for use with later references.<br/>(?:...) Grouping only. Group items into a single unit, but do not remember the characters that match this group.<br/>\n Match the same characters that were matched when group number n was first matched. Groups are sube&#173;xpressions within (possibly nested) parentheses. Group numbers are assigned by counting left parentheses from left to right. Groups formed with (?: are not numbered.<br/> <br/>5. Regular-e&#173;xpression anchor characters Character Meaning<br/>^ Match the beginning of the string and, in multiline searches, the beginning of a line.<br/>$ Match the end of the string and, in multiline searches, the end of a line.<br/>\b Match a word boundary. That is, match the position between a \w character and a \W character o&#114; between a \w character and the beginning o&#114; end of a string. (Note, however, that [\b] matches backspace.)<br/>\B Match a position that is not a word boundary.<br/>(?=p) A positive lookahead assertion. Require that the following characters match the pattern p, but do not include those characters in the match.<br/>(?!p) A negative lookahead assertion. Require that the following characters do not match the pattern p.<br/> <br/>6. Regular-e&#173;xpression flags Character Meaning<br/>i Perform case-insensitive matching.<br/>g Perform a global matchthat is, find all matches rather than stopping after the first match.<br/>m Multiline mode. ^ matches beginning of line o&#114; beginning of string, and $ matches end of line o&#114; end of string.<br/> <br/><br/><br/>string.replace(regexp, replacement)<br/><br/><br/>Characters Replacement<br/>$1, $2, ..., $99&nbsp;&nbsp;The text that matched the 1st through 99th parenthesized sube&#173;xpression within regexp<br/>$&amp;&nbsp;&nbsp;The substring that matched regexp<br/>$&#39;&nbsp;&nbsp;The text to the left of the matched substring<br/>$&#39;&nbsp;&nbsp;The text to the right of the matched substring<br/>$$&nbsp;&nbsp;A literal dollar sign<br/> <br/>name.replace(/(\w+)\s*,\s*(\w+)/, &#34;$2 $1&#34;);<br/>text.replace(/&#34;([^&#34;]*)&#34;/g, &#34;&#39;&#39;$1&#39;&#39;&#34;);<br/>text.replace(/\b\w+\b/g, function(word) {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return word.substring(0,1).toUpperCase( ) +<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;word.substring(1);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=104</link>
			<title><![CDATA[javascript设法提高循环的性能 ]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[JavaScript]]></category>
			<pubDate>Thu,25 Feb 2010 17:19:29 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=104</guid>	
		<description><![CDATA[一般在javascript里对数组进行遍历一般是使用for循环，像下面一样<br/><br/> <br/><br/>var arr = [];<br/>for(var i=0; i&lt;arr.length; i++){<br/>&nbsp;&nbsp;//loop<br/>} <br/><br/>这种代码最大的问题，就在于每次循环时都要通过 .操作符获取 .length，增加了开销。那么我们可以这样改进。<br/><br/> <br/><br/>var arr = [];<br/>for(var i=0, n=arr.length; i&lt;n; i++){<br/>&nbsp;&nbsp;//loop<br/>} <br/><br/>这样子，先把 arr.length暂存到 n 变量中去。只在开始时获取一次。<br/><br/>但是这样就没问题了吗？貌似多定义了个无意义的变量 n 。好那继续改进<br/><br/> <br/><br/>var arr = [];<br/>for(var i=arr.length-1; i &gt; -1; i--){<br/>&nbsp;&nbsp;//loop<br/>} <br/><br/>好这样子，我们把这个循环顺序倒过来，就把那个n去掉了，而使用了一个常量-1。<br/><br/> <br/><br/>如果应用场景，允许不使用 for 循环的话。我们可在使用 while代替<br/><br/> <br/><br/>善于使用这两种循环语句，以提高javascript的效率。<br/><br/> <br/><br/> <br/><br/>var arr = [];<br/>var i=arr.length-1;<br/>while(i--){<br/>&nbsp;&nbsp;//loop arr[i]<br/>}<br/> <br/><br/>或者<br/><br/> <br/><br/>var arr = [];<br/>var i=arr.length-1;<br/>do {<br/>&nbsp;&nbsp;// loop arr[i]<br/>}while(--i) <br/><br/>这样代码更简洁，效率更好，特别是如果允许先执行一次循环体的情况下，使用do while效果很明显。<br/><br/>唯一的问题是把 i 移到循环外了。 <br/><br/> <br/>]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=103</link>
			<title><![CDATA[javascript设法提高循环的性能 ]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[JavaScript]]></category>
			<pubDate>Thu,25 Feb 2010 17:15:25 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=103</guid>	
		<description><![CDATA[一般在javascript里对数组进行遍历一般是使用for循环，像下面一样<br/><br/> <br/><br/>var arr = [];<br/>for(var i=0; i&lt;arr.length; i++){<br/>&nbsp;&nbsp;//loop<br/>} <br/><br/>这种代码最大的问题，就在于每次循环时都要通过 .操作符获取 .length，增加了开销。那么我们可以这样改进。<br/><br/> <br/><br/>var arr = [];<br/>for(var i=0, n=arr.length; i&lt;n; i++){<br/>&nbsp;&nbsp;//loop<br/>} <br/><br/>这样子，先把 arr.length暂存到 n 变量中去。只在开始时获取一次。<br/><br/>但是这样就没问题了吗？貌似多定义了个无意义的变量 n 。好那继续改进<br/><br/> <br/><br/>var arr = [];<br/>for(var i=arr.length-1; i &gt; -1; i--){<br/>&nbsp;&nbsp;//loop<br/>} <br/><br/>好这样子，我们把这个循环顺序倒过来，就把那个n去掉了，而使用了一个常量-1。<br/><br/> <br/><br/>如果应用场景，允许不使用 for 循环的话。我们可在使用 while代替<br/><br/> <br/><br/>善于使用这两种循环语句，以提高javascript的效率。<br/><br/> <br/><br/> <br/><br/>var arr = [];<br/>var i=arr.length-1;<br/>while(i--){<br/>&nbsp;&nbsp;//loop arr[i]<br/>}<br/> <br/><br/>或者<br/><br/> <br/><br/>var arr = [];<br/>var i=arr.length-1;<br/>do {<br/>&nbsp;&nbsp;// loop arr[i]<br/>}while(--i) <br/><br/>这样代码更简洁，效率更好，特别是如果允许先执行一次循环体的情况下，使用do while效果很明显。<br/><br/>唯一的问题是把 i 移到循环外了。 <br/><br/> <br/><br/>Tag标签: javascript<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=102</link>
			<title><![CDATA[强制关闭网页不征求浏览器确认框]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[JavaScript]]></category>
			<pubDate>Thu,25 Feb 2010 17:14:45 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=102</guid>	
		<description><![CDATA[window.opener=null;&nbsp;&nbsp;&nbsp;&nbsp;<br/>window.open(&#34;&#34;,&#39;_self&#39;,&#34;&#34;);&nbsp;&nbsp;&nbsp;&nbsp;<br/>window.close();&nbsp;&nbsp;]]></description>
		</item>
		
			<item>
			<link>http://www.caifuzhu.com.cn/default.asp?id=101</link>
			<title><![CDATA[nginx+tomcat架构下获取真实IP的办法 ]]></title>
			<author>zhouhaizhe@126.com(admin)</author>
			<category><![CDATA[java随写]]></category>
			<pubDate>Sun,14 Feb 2010 13:07:50 +0800</pubDate>
			<guid>http://www.caifuzhu.com.cn/default.asp?id=101</guid>	
		<description><![CDATA[第一步：在nginx.conf中配置反向代理时把真实IP带上，例如：<br/><br/>server { <br/>&nbsp;&nbsp;&nbsp;&nbsp;listen 80; <br/>&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;boyan.com; <br/>&nbsp;&nbsp;&nbsp;&nbsp;location ~ ^/(WEB-INF)/ { <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deny all; <br/>&nbsp;&nbsp;&nbsp;&nbsp; } <br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;location / { <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass <a href="http://localhost:8888" target="_blank">http://localhost:8888</a>; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;&nbsp;X-Real-IP&nbsp;&nbsp;$remote_addr;<br/>&nbsp;&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;}<br/><br/>第二步：应用程序中用 String ip = request.getHeader(&#34;X-Real-IP&#34;);替代String ip = request.getRemoteAddr();即可<br/>转：<a href="http://www.blogjava.net/boyanxiu/archive/2010/02/09/312411.html" target="_blank">http://www.blogjava.net/boyanxiu/archive/2010/02/09/312411.html</a><br/><br/>]]></description>
		</item>
		
</channel>
</rss>