??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲av专区无码观看精品天堂,国产亚洲女在线线精品,亚洲人成在线中文字幕http://www.tkk7.com/huanghuizz/category/14530.htmlzh-cnSun, 19 Jul 2009 13:27:07 GMTSun, 19 Jul 2009 13:27:07 GMT60DOCTYPE! HTML PUBLIC 声明规范http://www.tkk7.com/huanghuizz/articles/287340.html七匹?/dc:creator>七匹?/author>Sun, 19 Jul 2009 08:08:00 GMThttp://www.tkk7.com/huanghuizz/articles/287340.htmlhttp://www.tkk7.com/huanghuizz/comments/287340.htmlhttp://www.tkk7.com/huanghuizz/articles/287340.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/287340.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/287340.html

DOCTYPE的常用声明:按照 HTML 4.01 XHTML 1.0 XHTML 1.1 列表如下Q错误的DOCTYPE HTML PUBLIC反而会D面解析错误?/p>

HTML 4.01规范分ؓQStrict, Transitional, Frameset

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

 

XHTML 1.0规范分ؓQStrict, Transitional, Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

 

XHTML 1.1 DTD

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


]]>
tomcat 调优以及jconsole监控 配置http://www.tkk7.com/huanghuizz/articles/257060.html七匹?/dc:creator>七匹?/author>Fri, 27 Feb 2009 08:26:00 GMThttp://www.tkk7.com/huanghuizz/articles/257060.htmlhttp://www.tkk7.com/huanghuizz/comments/257060.htmlhttp://www.tkk7.com/huanghuizz/articles/257060.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/257060.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/257060.html
上面是在本地监测Q如果远E监,如下Q?br />
要实现远E监控还要与IPl定Q添加参敎ͼ
    -Djava.rmi.server.hostname=192.168.10.31

    若要实现使用用户名登陆,修改参数-Dcom.sun.management.jmxremote.authenticate=trueQ?br />     d启动参数Q?Dcom.sun.management.jmxremote.password.file=$JAVA_HOME/jre/lib/management/jmxremote.password Q?br /> 然后q行以下配置Q?br /> 1. ?JRE_HOME/lib/management/jmxremote.password.template拯?/code>jmxremote.password?br /> 2. L此目录下 jmxremote.access 最后两行的注释Q这个存的就是用户名和权限?br /> 3. 对应的,L jmxremote.password 最后两行注释,q个是用户名和对应的密码?br /> 4. 通过d和修改这两个文g来管理登陆用戗?br />
最后,要修?code>jmxremote.password
文g的权限chkmod 600 jmxremote.password?br />    可以在Jconsole里实现远E监控了Q?br />    q程q程 192.168.10.31:8950
   ?service:jmx:rmi:///jndi/rmi://192.168.10.31:8950/jmxrmi


]]>
java性能?,5个用?/title><link>http://www.tkk7.com/huanghuizz/articles/255909.html</link><dc:creator>七匹?/dc:creator><author>七匹?/author><pubDate>Fri, 20 Feb 2009 15:58:00 GMT</pubDate><guid>http://www.tkk7.com/huanghuizz/articles/255909.html</guid><wfw:comment>http://www.tkk7.com/huanghuizz/comments/255909.html</wfw:comment><comments>http://www.tkk7.com/huanghuizz/articles/255909.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/huanghuizz/comments/commentRss/255909.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/huanghuizz/services/trackbacks/255909.html</trackback:ping><description><![CDATA[<ol class="dp-j"> <li><span><span id="olzdmuw" class="keyword">private</span><span> </span><span id="gldwvro" class="keyword">static</span><span> Credit BaseCredit = </span><span id="kggyamj" class="keyword">new</span><span> Credit();   </span></span> </li> <li><span id="efmmpbn" class="keyword">public</span><span> </span><span id="ugoetmc" class="keyword">static</span><span> Credit getNewCredit() {   </span> </li> <li><span id="qbqjfyz" class="keyword">return</span><span> (Credit) BaseCredit.clone();   </span> </li> <li><span>}   </span> </li> </ol> <pre class="java" style="display: none;" name="code">private static Credit BaseCredit = new Credit(); public static Credit getNewCredit() { return (Credit) BaseCredit.clone(); } </pre> <p> Java语言习惯用语<br /> <strong>1.循环</strong><br />       ?在重要的循环里,消除循环l止判断时的Ҏ调用。。?br />       例如Q将...bt   <a >www.bt285.cn</a>      </p> <div id="tqmbqno" class="dp-highlighter"><span><span id="galpamk" class="keyword">for</span><span>(</span><span id="ugyjurh" class="keyword">int</span><span> i=</span><span id="mufzuyc" class="number">0</span><span>; i<collection.size();i++){   </span></span> <ol class="dp-j"> <li><span>       ...   </span> </li> <li><span>      }  </span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">for(int i=0; i<collection.size();i++){ ... } </pre> <p> </p> <p>      替换?#8230;<br />       </p> <div id="iubqmfn" class="dp-highlighter"> <ol class="dp-j"> <li><span><span id="grixmug" class="keyword">for</span><span>(</span><span id="emmujgh" class="keyword">int</span><span> i=</span><span id="gdohzst" class="number">0</span><span>; n=collection.size();i<n;i++){   </span></span> </li> <li><span>       ...   </span> </li> <li><span>      }  </span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">for(int i=0; n=collection.size();i<n;i++){ ... } </pre> <p> </p> <p>      ?通常Q把与@环index不相关的Ud循环的外?br />      </p> <div id="qycnyvw" class="dp-highlighter"> <div id="htaeliy" class="bar"> </div> <ol class="dp-j"> <li><span><span id="gshewtb" class="keyword">for</span><span>(</span><span id="iqqffjg" class="keyword">int</span><span> i=</span><span id="dmxmeif" class="number">0</span><span>; terminal=x.length;i<terminal;i++){   </span></span> </li> <li><span>        x[i] = x[i]/scaleA *scaleB;   </span> </li> <li><span>     }  </span> </li> </ol> </div> <pre class="java" style="display: none;" name="code"> for(int i=0; terminal=x.length;i<terminal;i++){ x[i] = x[i]/scaleA *scaleB; } </pre> <p> </p> <p>      应该该成Q?br />       </p> <div id="lxxiibr" class="dp-highlighter"> <div id="ebxxmfy" class="bar"> </div> <ol class="dp-j"> <li><span><span>Double scale =  scaleB*scaleA;   </span></span> </li> <li><span>      </span><span id="jgkhdwx" class="keyword">for</span><span>(</span><span id="juvoslq" class="keyword">int</span><span> i=</span><span id="extbbai" class="number">0</span><span>; terminal=x.length;i<terminal;i++){   </span> </li> <li><span>         x[i] = x[i]/scale ;   </span> </li> <li><span>      }  </span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">Double scale = scaleB*scaleA; for(int i=0; terminal=x.length;i<terminal;i++){ x[i] = x[i]/scale ; } </pre> <p> </p> <p><strong>2.字符?/strong><br />      ?消除字符串连?br />      ?创徏长字W串ӞL使用StringBuffter代替String<br />      ?预先分配StringBufferI间   StringBuffer sb = new StringBuffer(5000);</p> <p><strong></strong></p> <p><strong>3.基本数据cd<br /> </strong>     ?在重要的循环里用基本数据类型(int型数据通常比long/double型数据更快)<br />      ?基本数据cdQBoolean,Integer,etcQ的包装cM要用在当传递的Ҏ参数必须是一个对象的引用Ӟ而不是一个基本数据类型)<br />      ?Ҏ有的帔R代数表达式用static final修饰W?br />      ?使常量更Ҏ引用Q编译器预先计算帔R表达式)</p> <p> </p> <p><strong>4.异常</strong><br />      ?异常只用于单个真正的错误条g 如小?20|?<a >www.5a520.cn</a> 抛出异常?br />          抛出一个异常和执行一个catch代码块花Ҏ很高的(主要׃当创Z个异常时要获得线E栈的一个快照)<br />          只当条g真的异常时才抛出一个异?/p> <p>     ?抛出异常首先要创Z个新的对象?/p> <p>         Throwable接口的构造函数调用名为fillInStackTrace()的本圎ͼNativeQ方法,fillInStackTrace()Ҏ查堆栈,攉调用跟踪信息?/p> <p>         只要有异常被抛出QVM必调整调用堆栈,因ؓ在处理过E中创徏了一个新的对象?</p> <p>     异常只能用于错误处理Q不应该用来控制E序程?br />      ?使编译器和运行时最优化Q将几个Ҏ调用攑֜一个try/catch块中Q而不是ؓ每个Ҏ调用实现几个try/catch?/p> <p>      </p> <div id="ozgkgdt" class="dp-highlighter"> <div id="jrygvkh" class="bar"> </div> <ol class="dp-j"> <li><span><span id="nrcknkl" class="keyword">try</span><span>{   </span></span> </li> <li><span>        Some.method1();   </span><span id="ckowspx" class="comment">//Difficut for java1.4 </span><span>  </span> </li> <li><span>    }</span><span id="jyynygd" class="keyword">catch</span><span>(method1Exception e){   </span> </li> <li><span>        handle exception </span><span id="jnjcucg" class="number">1</span><span>  </span><span id="ynfcjcl" class="comment">// to optimize this code </span><span>  </span> </li> <li><span>    }   </span> </li> <li><span>         </span> </li> <li><span id="dpppabn" class="keyword">try</span><span>{   </span> </li> <li><span>        Some.method2();   </span><span id="kwwwweu" class="comment">//Difficut for java1.4 </span><span>  </span> </li> <li><span>     }</span><span id="wiiqfrf" class="keyword">catch</span><span>(method2Exception e){   </span> </li> <li><span>        handle exception </span><span id="kkgzzwx" class="number">2</span><span>  </span><span id="rrgvczi" class="comment">// to optimize this code </span><span>  </span> </li> <li><span>     }   </span> </li> <li><span>         </span> </li> <li><span id="cgrgvst" class="keyword">try</span><span>{   </span> </li> <li><span>         Some.method3();   </span><span id="urcrrol" class="comment">//Difficut for java1.4 </span><span>  </span> </li> <li><span>     }</span><span id="fnucgzl" class="keyword">catch</span><span>(method3Exception e){   </span> </li> <li><span>        handle exception </span><span id="qjquunz" class="number">3</span><span>  </span><span id="icccyrs" class="comment">// to optimize this code </span><span>  </span> </li> <li><span>    }  </span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">try{ Some.method1(); //Difficut for java1.4 }catch(method1Exception e){ handle exception 1 // to optimize this code } try{ Some.method2(); //Difficut for java1.4 }catch(method2Exception e){ handle exception 2 // to optimize this code } try{ Some.method3(); //Difficut for java1.4 }catch(method3Exception e){ handle exception 3 // to optimize this code } </pre> <p> </p> <p>   应该写ؓQ?/p> <div id="rsodzol" class="dp-highlighter"> <div id="qgrkrde" class="bar"> </div> <ol class="dp-j"> <li><span><span id="mfqqqgh" class="keyword">try</span><span>{   </span></span> </li> <li><span>      Some.method1();      </span> </li> <li><span>      Some.method2();      </span> </li> <li><span>      Some.method3();   </span><span id="pxxuqcz" class="comment">//Difficut for java1.4 </span><span>  </span> </li> <li><span>   }</span><span id="nzzovot" class="keyword">catch</span><span>(method1Exception e){   </span> </li> <li><span>       handle exception </span><span id="pbbfbuk" class="number">1</span><span>     </span> </li> <li><span>   }</span><span id="uyqyngh" class="keyword">catch</span><span>(method2Exception e){   </span> </li> <li><span>       handle exception </span><span id="ataepxj" class="number">2</span><span>     </span> </li> <li><span>   }</span><span id="ltalwtj" class="keyword">catch</span><span>(method3Exception e){   </span> </li> <li><span>       handle exception </span><span id="yzvovsl" class="number">3</span><span>     </span> </li> <li><span>   }  </span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">try{ Some.method1(); Some.method2(); Some.method3(); //Difficut for java1.4 }catch(method1Exception e){ handle exception 1 }catch(method2Exception e){ handle exception 2 }catch(method3Exception e){ handle exception 3 } </pre> <p><strong></strong> </p> <p><strong>5.基准</strong></p> <p>     ?注意Q所有这些技巧会因不同的q_和虚拟机而不?br />          一 例如Q在有些servlet容器内,通过一个OutputStream作ؓ字节输出会更?br />          一 在其它的容器内,通过一个PrintWriter输出字符会更?br />      ?q些技巧描q的是最可移植的<br />      ?你可能需要运行一些基准来判断在你的^C怎么h最快的</p> <p><strong></strong> </p> <p><strong>6.不用new关键词创建类的实?/strong> </p> <p>     ■用new关键词创建类的实例时Q构造函数链中的所有构造函数都会被自动调用?/p> <p>        但如果一个对象实CCloneable接口Q我们可以调用它的clone()Ҏ。clone()Ҏ不会调用McL造函数?/p> <p>        在用设计模式(Design PatternQ的场合Q如果用Factory模式创徏对象Q则改用clone()Ҏ创徏新的对象实例非常单?/p> <p>        例如Q下面是Factory模式的一个典型实玎ͼ</p> <p>         </p> <div id="lxalaxu" class="dp-highlighter"> <div id="oaaixbc" class="bar"> </div> <ol class="dp-j"> <li><span><span id="aqfyjjz" class="keyword">public</span><span> </span><span id="emptaiu" class="keyword">static</span><span> Credit getNewCredit() {   </span></span> </li> <li><span>   </span><span id="mqfyyrs" class="keyword">return</span><span> </span><span id="dwhpexn" class="keyword">new</span><span> Credit();   </span> </li> <li><span>  }   </span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">public static Credit getNewCredit() { return new Credit(); } </pre> <p>        优化后:</p> <div id="ebqfqjk" class="dp-highlighter"> <div id="tbxtatb" class="bar"> </div> <ol class="dp-j"> <li><span><span id="olswheb" class="keyword">private</span><span> </span><span id="daeipxy" class="keyword">static</span><span> Credit BaseCredit = </span><span id="qcyncgw" class="keyword">new</span><span> Credit();   </span></span> </li> <li><span id="fccgksa" class="keyword">public</span><span> </span><span id="vdkoowi" class="keyword">static</span><span> Credit getNewCredit() {   </span> </li> <li><span>    </span><span id="ijyrcoa" class="keyword">return</span><span> (Credit) BaseCredit.clone();   </span> </li> <li><span>}   </span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">private static Credit BaseCredit = new Credit(); public static Credit getNewCredit() { return (Credit) BaseCredit.clone(); } </pre> <p>       上面的思\对于数组处理同样很有用?/p> <p>      </p> <p><strong>7.使用非阻塞I/O</strong> <strong> </strong></p> <p><strong>      </strong>?strong>Java</strong>版本较低的JDK不支持非dI/O API。ؓ避免I/OdQ一些应用采用了创徏大量U程的办法(在较好的情况下,会用一个缓冲池Q。这U技术可以在许多必须支持q发I/O的应用中见 刎ͼ如Web服务器、报价和拍卖应用{。然而,创徏JavaU程需要相当可观的开销?</p> <p>    JDK 1.4引入了非d的I/O库(java.nioQ。如果应用要求用版本较早的JDKQ在q里有一个支持非dI/O的Y件包?/p> <p> </p> <p><strong>8.不要重复初始化变?/strong> <strong> </strong></p> <p><strong>      </strong>■默认情况下Q调用类的构造函数时Q?Java会把变量初始化成定的|所有的对象被设|成nullQ整数变量(byte、short、int、longQ设|成0Qfloat?double变量讄?.0Q逻辑D|成false?/p> <p>      当一个类从另一个类zӞq一点尤其应该注意,因ؓ用new关键词创Z个对象时Q构造函数链中的所有构造函数都会被自动调用?/p> <p> </p> <p><strong>9.量指定cȝfinal修饰W?/strong> <strong> </strong></p> <p><strong>       </strong>■带有final修饰W的cL不可z的。在Java核心API中,有许多应用final的例子,例如java.lang.String。ؓStringcL定final防止了h们覆盖length()Ҏ?</p> <p>   另外Q如果指定一个类为finalQ则该类所有的Ҏ都是final。Java~译器会LZ内联QinlineQ所有的finalҎQ这和具体的~译器实现有养I。此举能够性能q_提高50%?/p> <p> </p> <p><strong>10.量使用局部变?/strong> <strong> </strong></p> <p><strong>       </strong>■调用方法时传递的参数以及在调用中创徏的时变量都保存在栈QStackQ中Q速度较快。其他变量,如静态变量、实例变量等Q都在堆QHeapQ中创徏Q速度较慢。另外,依赖于具体的~译?JVMQ局部变量还可能得到q一步优化。请参见《尽可能使用堆栈变量》?/p> <p> </p> <p><strong>11.乘法和除?/strong> <strong> </strong></p> <p><strong>       </strong>■考虑下面的代?</p> <div id="jryyjrk" class="dp-highlighter"> <div id="cogzgzl" class="bar"> </div> <ol class="dp-j"> <li><span><span id="pfuuuno" class="keyword">for</span><span> (val = </span><span id="xjjccze" class="number">0</span><span>; val < </span><span id="eqmmxfv" class="number">100000</span><span>; val +=</span><span id="xqiieqg" class="number">5</span><span>) { alterX = val * </span><span id="ykvrrzl" class="number">8</span><span>; myResult = val * </span><span id="qcncrzt" class="number">2</span><span>; }   </span></span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">for (val = 0; val < 100000; val +=5) { alterX = val * 8; myResult = val * 2; } </pre> <p>        优化后:</p> <div id="lmmjuno" class="dp-highlighter"> <div id="zlwppeb" class="bar"> </div> <ol class="dp-j"> <li><span><span id="urckvsd" class="keyword">for</span><span> (val = </span><span id="urvokyk" class="number">0</span><span>; val < </span><span id="hawaltn" class="number">100000</span><span>; val += </span><span id="hpemmqv" class="number">5</span><span>) { alterX = val << </span><span id="tmxxiqn" class="number">3</span><span>; myResult = val << </span><span id="oeppatb" class="number">1</span><span>; }   </span></span> </li> </ol> </div> <pre class="java" style="display: none;" name="code">for (val = 0; val < 100000; val += 5) { alterX = val << 3; myResult = val << 1; } </pre> <p> </p>        修改后的代码不再做乘?的操作,而是改用{h的左U?位操作,每左U?位相当于乘以2。相应地Q右U?位操作相当于除以2。值得一提的是,虽然UM操作速度快,但可能代码比较难于理解Q所以最好加上一些注释?nbsp; <img src ="http://www.tkk7.com/huanghuizz/aggbug/255909.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/huanghuizz/" target="_blank">七匹?/a> 2009-02-20 23:58 <a href="http://www.tkk7.com/huanghuizz/articles/255909.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>多反向代理下获取客L真实IP地址 http://www.tkk7.com/huanghuizz/articles/188234.html七匹?/dc:creator>七匹?/author>Mon, 24 Mar 2008 06:23:00 GMThttp://www.tkk7.com/huanghuizz/articles/188234.htmlhttp://www.tkk7.com/huanghuizz/comments/188234.htmlhttp://www.tkk7.com/huanghuizz/articles/188234.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/188234.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/188234.html
q段旉在做IPl计的程序设计,׃服务器作了集,使用了反向代理YӞhttp://192.168.1.110:2046/? URL反向代理为http://www.xxx.com/的URLӞ用request.getRemoteAddr()Ҏ获取的IP地址是: 127.0.0.1 或 192.168.1.110Q而ƈ不是客户端的真实QP。这是什么原因呢Q?

q是反向代理的原因。经q代理以后,׃在客L和服务之间增加了中间层,因此服务器无法直接拿到客L的IPQ服务器端应用也无法直接通过 转发h的地址q回l客L。但是在转发h的HTTP头信息中Q增加了XQFORWARDEDQFOR信息。用以跟t原有的客户端IP地址和原来客L h的服务器地址。当我们讉Khttp://www.xxx.com/index.jsp/Ӟ其实q不是我们浏览器真正讉KC服务器上? index.jsp文gQ而是先由代理服务器去讉Khttp://192.168.1.110:2046/index.jspQ代理服务器再将讉K到的l? 果返回给我们的浏览器Q因为是代理服务器去讉Kindex.jsp的,所以index.jsp中通过request.getRemoteAddr()的方 法获取的IP实际上是代理服务器的地址Qƈ不是客户端的IP地址?

于是可得得客L真实IP地址的方法一Q?

1 public String getIpAddr(HttpServletRequest request) {
2 String ip = request.getHeader("x-forwarded-for");
3 if(ip == null || ip.length() == 0) {
4 ip = request.getRemoteAddr();
5 }
6 return ip;
7 }
可是当我讉Khttp://www.xxx.com/index.jsp/Ӟq回的IP地址始终是unknownQ也q不是如上所C的 127.0.0.1 或 192.168.1.110了,而我讉Khttp://192.168.1.110:2046/index.jspӞ则能q回 客户端的真实IP地址Q写了个Ҏ去验证?

1<%@ page import="java.util.*" %>
2<table border=1 cellspacing=0 cellpadding=0 align=center>
3<tr>
4<th>Name</th>
5<th>Value</th>
6</tr>
7<%
8Enumeration enumNames;
9String strName,strValue;
10
11enumNames = request.getHeaderNames();
12while(enumNames.hasMoreElements()){
13 strName = (String)enumNames.nextElement();
14 strValue = request.getHeader(strName);
15 %>
16 <tr>
17 <td><%=strName%></td>
18 <td><%=strValue%></td>
19 </tr>
20 <%
21}
22%>
23<tr>
24</table>
25

出来的结果:X-Forwarded-For: unknown 。X-Forwarded-For实存在Q但其值却为unknownQl找原因。上|搜了搜Q原因出在了Squid上?

squid.conf 的配制文件 forwarded_for w认是为onQ如?forwarded_for 设成?off  则:

X-Forwarded-For: unknown

一查,发现forwarded_for 设ZoffQ原因找CQ把forwarded_for 设ZonQ重启后Q访问http://www.xxx.com/index.jsp/ 获得的IP是客L的真实IP?

于是可得得客L真实IP地址的方法二Q?

1 public String getIpAddr(HttpServletRequest request) {
2 String ip = request.getHeader("x-forwarded-for");
3 if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
4 ip = request.getHeader("Proxy-Client-IP");
5 }
6 if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
7 ip = request.getHeader("WL-Proxy-Client-IP");
8 }
9 if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
10 ip = request.getRemoteAddr();
11 }
12 return ip;
13 }
14


可是Q如果通过了多U反向代理的话,X-Forwarded-For的值ƈ不止一个,而是一Ԍp|I竟哪个才是真正的用L的真实IP呢?

{案是取X-Forwarded-For中第一个非unknown的有效IP字符丌Ӏ?

如:
X-Forwarded-ForQ?92.168.1.110, 192.168.1.120, 192.168.1.130, 192.168.1.100
用户真实IP为: 192.168.1.110

引用Qhttp://zhangljerry.javaeye.com/blog/91638


]]>
Log4J 最佛_践之全能配置文ghttp://www.tkk7.com/huanghuizz/articles/188147.html七匹?/dc:creator>七匹?/author>Mon, 24 Mar 2008 01:52:00 GMThttp://www.tkk7.com/huanghuizz/articles/188147.htmlhttp://www.tkk7.com/huanghuizz/comments/188147.htmlhttp://www.tkk7.com/huanghuizz/articles/188147.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/188147.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/188147.html
log4j.rootLogger=DEBUG,CONSOLE,A1,im
#DEBUG,CONSOLE,FILE,ROLLING_FILE,MAIL,DATABASE

log4j.addivity.org.apache=true


###################
# Console Appender
###################
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.Threshold=DEBUG
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n
#log4j.appender.CONSOLE.layout.ConversionPattern=[start]%d{DATE}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD] n%c[CATEGORY]%n%m[MESSAGE]%n%n


#####################
# File Appender
#####################
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=file.log
log4j.appender.FILE.Append=false
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n
# Use this layout for LogFactor 5 analysis



########################
# Rolling File
########################
log4j.appender.ROLLING_FILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLING_FILE.Threshold=ERROR
log4j.appender.ROLLING_FILE.File=rolling.log
log4j.appender.ROLLING_FILE.Append=true
log4j.appender.ROLLING_FILE.MaxFileSize=10KB
log4j.appender.ROLLING_FILE.MaxBackupIndex=1
log4j.appender.ROLLING_FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLING_FILE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n


####################
# Socket Appender
####################
log4j.appender.SOCKET=org.apache.log4j.RollingFileAppender
log4j.appender.SOCKET.RemoteHost=localhost
log4j.appender.SOCKET.Port=5001
log4j.appender.SOCKET.LocationInfo=true
# Set up for Log Facter 5
log4j.appender.SOCKET.layout=org.apache.log4j.PatternLayout
log4j.appender.SOCET.layout.ConversionPattern=[start]%d{DATE}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD]%n%c[CATEGORY]%n%m[MESSAGE]%n%n


########################
# Log Factor 5 Appender
########################
log4j.appender.LF5_APPENDER=org.apache.log4j.lf5.LF5Appender
log4j.appender.LF5_APPENDER.MaxNumberOfRecords=2000


########################
# SMTP Appender
#######################
log4j.appender.MAIL=org.apache.log4j.net.SMTPAppender
log4j.appender.MAIL.Threshold=FATAL
log4j.appender.MAIL.BufferSize=10
log4j.appender.MAIL.From=chenyl@hollycrm.com
log4j.appender.MAIL.SMTPHost=mail.hollycrm.com
log4j.appender.MAIL.Subject=Log4J Message
log4j.appender.MAIL.To=chenyl@hollycrm.com
log4j.appender.MAIL.layout=org.apache.log4j.PatternLayout
log4j.appender.MAIL.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n


########################
# JDBC Appender
#######################
log4j.appender.DATABASE=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.DATABASE.URL=jdbc:mysql://localhost:3306/test
log4j.appender.DATABASE.driver=com.mysql.jdbc.Driver
log4j.appender.DATABASE.user=root
log4j.appender.DATABASE.password=
log4j.appender.DATABASE.sql=INSERT INTO LOG4J (Message) VALUES ('[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n')
log4j.appender.DATABASE.layout=org.apache.log4j.PatternLayout
log4j.appender.DATABASE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n


log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A1.File=SampleMessages.log4j
log4j.appender.A1.DatePattern=yyyyMMdd-HH'.log4j'
log4j.appender.A1.layout=org.apache.log4j.xml.XMLLayout

###################
#自定义Appender
###################
log4j.appender.im = net.cybercorlin.util.logger.appender.IMAppender

log4j.appender.im.host = mail.cybercorlin.net
log4j.appender.im.username = username
log4j.appender.im.password = password
log4j.appender.im.recipient = corlin@cybercorlin.net

log4j.appender.im.layout=org.apache.log4j.PatternLayout
log4j.appender.im.layout.ConversionPattern =[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n

引用 Qhttp://www.dingl.com/view.shtml?xh=485


]]>
amcharts漂亮报表 破解http://www.tkk7.com/huanghuizz/articles/181919.html七匹?/dc:creator>七匹?/author>Mon, 25 Feb 2008 02:48:00 GMThttp://www.tkk7.com/huanghuizz/articles/181919.htmlhttp://www.tkk7.com/huanghuizz/comments/181919.htmlhttp://www.tkk7.com/huanghuizz/articles/181919.html#Feedback1http://www.tkk7.com/huanghuizz/comments/commentRss/181919.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/181919.htmlamcharts漂亮报表
http://www.amcharts.com/download

破解ҎQ?
今天介绍破解amcharts的方法一Q从swf文g入手?
用SWF Decompiler软g加蝲swf文gQ在Resources下找Action中的MainMoiveQ代码中有一D如下:
function checkKey(serial)
{
var _l1 = com.amcharts.Utils.stripSymbols(serial, " ");
_l1 = com.amcharts.Utils.stripSymbols(_l1, "\n");
_l1 = com.amcharts.Utils.stripSymbols(_l1, "\r");
_l1 = com.amcharts.Utils.stripSymbols(_l1, "\r\n");
arr = _l1.split("-");
if (Number(arr[2]) + Number(arr[3]) != 8645 || Number(arr[2].substr(1, 1)) - Number(arr[3].substr(2, 1)) != 2)
{
attachMovie("copyright_mc", "copyright_mc", 1001);
} // end if
} // End of the function
q就是序列号的代码,再往下看
key_loader.loadVars(path + "amcharts_key.txt", this, "checkKey", false, "checkKey");
到这里,学过一点基~程的都看明白了?
? -"作ؓ序列L链接W号Q第二个链接W号后的?W三个符号后的数=8645Qƈ且第二个链接W号后的C的第一位数后面的一位数-W三个符号后的数中的W二位数后面的一位数=2Q只要满三个条g的序列号可以了Q然后把q个序列号保存在swf文g相同文g夹下?span class="hilite1">amcharts_key.txt 中,看来作者的注册方式极ؓ单~
下蝲以下序列hӞ解压到swf文g的目?

]]>
Java2 q算W?/title><link>http://www.tkk7.com/huanghuizz/articles/163954.html</link><dc:creator>七匹?/dc:creator><author>七匹?/author><pubDate>Thu, 29 Nov 2007 03:35:00 GMT</pubDate><guid>http://www.tkk7.com/huanghuizz/articles/163954.html</guid><wfw:comment>http://www.tkk7.com/huanghuizz/comments/163954.html</wfw:comment><comments>http://www.tkk7.com/huanghuizz/articles/163954.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/huanghuizz/comments/commentRss/163954.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/huanghuizz/services/trackbacks/163954.html</trackback:ping><description><![CDATA[<p style="text-indent: 2em">?-7 Java q算W优先 <p style="text-indent: 2em">最? <p style="text-indent: 2em">( ) [ ] . <p style="text-indent: 2em">++ – – ~ ! <p style="text-indent: 2em">* / % <p style="text-indent: 2em">+ – <p style="text-indent: 2em">>> >>> << <p style="text-indent: 2em">> >= < <= <p style="text-indent: 2em">l表 <p style="text-indent: 2em">== != <p style="text-indent: 2em">& <p style="text-indent: 2em">^ <p style="text-indent: 2em">| <p style="text-indent: 2em">&& <p style="text-indent: 2em">|| <p style="text-indent: 2em">?: <p style="text-indent: 2em">= op= <p style="text-indent: 2em">最?</p> <img src ="http://www.tkk7.com/huanghuizz/aggbug/163954.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/huanghuizz/" target="_blank">七匹?/a> 2007-11-29 11:35 <a href="http://www.tkk7.com/huanghuizz/articles/163954.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>学习使用 Manifesthttp://www.tkk7.com/huanghuizz/articles/163379.html七匹?/dc:creator>七匹?/author>Tue, 27 Nov 2007 01:30:00 GMThttp://www.tkk7.com/huanghuizz/articles/163379.htmlhttp://www.tkk7.com/huanghuizz/comments/163379.htmlhttp://www.tkk7.com/huanghuizz/articles/163379.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/163379.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/163379.html 发布Java应用E序时你会感到困难?好在Java提供了一pd打包和发布工P可以显著的简化发布过E?
该文章提供了打包Java code的几U方法,我们会探讨Java manifest 文gQ给出用于管理JAR文g所依赖文g、估计跨q_发布所需的CLasspath的合适方?我也会解释如何用manifest包版本特性来认包的兼容?..

什么是JAR文gQ?

在开发过E中Q我们可以直接用Java class文g来运行程序,但这q不是一个好方式Q好在Java 提供?JAR(Java Archive)文g来提供发布和q行?

jar 文g实际上是class 文g的ZIP压羃存档Q这U格式被q泛使用Q因此易与用,有很多中工具可以操作q种格式的文件。也正是因ؓq个原因Qjar文g本nq不能表达所包含应用E序的标{信息?

Manifest 因此得以出现

Z要提供存档的标签信息Qjar 文g指定了一个特定目录来存放标签信息QMETA-INF 目录Q其中我们来x该目录中的MANIFEST.MF文gQ他是JAR的manifest文gQ他包含了JAR文g的内Ҏqͼq在q行时向JVM提供应用E序的信息,大多数JAR文g含有一个默认生成的manifest 文g,执行JAR命o或用zip工具Q都可以产生?

如果是由jar命o产生?manifest 文gQŞ?

Manifest-Version: 1.0
Created-By:1.4.0-beta
(Sun Microsystems Inc.)

q些信息没甚么用,仅仅告诉我们使用的是1.0的manifest文g,W一行定义manifest的格式,W二行说明?SUN 的JDK1.4的jar工具生成该文Ӟ如果manifest文g是由其他 Q如antQ?创徏的,那将会出?“Created-By: Ant 1.2” 之类的内容,如果你是自己创徏manifest文gQ你可以加入自己的一些相关信?

基础格式

manifest 文g的格?是很单的Q每一行都?名-?对应?属性名开_接着?":" Q然后是属性|每行最?2个字W,如果需要增加,你可以在下一行箋行,l行以空格开_以空格开头的行都会被视ؓ前一行的l行?

所有在开头的属性都是全局的,你也可以定义特定class 或package的属性,E后介l这U?

把manifest文g插入JAR文g

使用 m 选项Q把指定文g名的manifest文g 传入Q例?

jar cvfm myapplication.jar myapplication.mf -C classdir

如果你用ant来创建时Q在ant 的build.xml 加入如下条目

<target name="jar">
<jar jarfile ="myapplication.jar"
manifest="myapplication.mf">
<fileset dir="classdir"
includes="**/*.class"/>
</jar>
</target>

q行JavaE序

现在我们来体验一下manifest文g的作用,如果现在我们有一个Java 应用E序打包在myapplication.jar中, main class?com.example.myapp.MyAppMain Q那么我们可以用以下的命令来q行

java -classpath myapplication.jar com.example.myapp.MyAppMain

q显然太ȝ了,现在我们来创qmanifest文gQ如下:

Manifest-Version: 1.0
Created-By: JDJ example
Main-Class: com.example.myapp.MyAppMain

q样我们可以用如下的命o来运行程序了Q(明显单多了,也不会造成无谓的拼写错误)

java -jar myapplication.jar

理JAR的依赖资?

很少Java应用会仅仅只有一个jar文gQ一般还需?其他cd。比如我的应用程序用CSun ?Javamail classes Q在classpath中我需要包含activation.jar ?mail.jar,q样在运行程序时,相比上面的例?我们要增加一?

java -classpath mail.jar:activation.jar -jar myapplication.jar

在不同的操作pȝ?jar包间的分隔符也不一P在UNIX?#8220;Q?#8221;Q在window中?“Q?#8221;Q这样也不方?

同样Q我们改写我们的manifest文gQ如?

Manifest-Version: 1.0
Created-By: JDJ example
Main-Class: com.example.myapp.MyAppMain
Class-Path: mail.jar activation.jar

Q加入了Class-Path: mail.jar activation.jarQ用I格分隔两个jar包)

q样我们仍然可以使用和上例中相同的命令来执行该程序:

java -jar myapplication.jar

Class-Path属性中包含了用I格分隔的jar文gQ在q些jar文g名中要对特定的字W用逃逸符Q比如空|要表C成"%20"Q在路径的表CZQ都采用“/”来分隔目录,无论是在什么操作系l中Q?即在window?Q而且q里用的是相对\径(相对于本w的JAR文gQ:

Manifest-Version: 1.0
Created-By: JDJ example
Main-Class: com.example.myapp.MyAppMain
Class-Path: ext/mail.jar ext/activation.jar


Multiple Main ClassesQ多ȝQ?
q有一UMultiple Main Classes情况Q如果你的应用程序可能有命o行版?和GUI版本Q或者一些不同的应用却共享很多相同的代码Q这时你可能有多个Main ClassQ我们徏议你采取q样的策略:把共享的cL成lib包,然后把不同的应用打成不同的包Q分别标志主c:如下


Manifest for myapplicationlib.jar:
Manifest-Version: 1.0
Created-By: JDJ example
Class-Path: mail.jar activation.jar

Manifest for myappconsole.jar:
Manifest-Version: 1.0
Created-By: JDJ example
Class-Path: myapplicationlib.jar
Main-Class: com.example.myapp.MyAppMain

Manifest for myappadmin.jar:
Manifest-Version: 1.0
Created-By: JDJ example
Class-Path: myapplicationlib.jar
Main-Class: com.example.myapp.MyAdminTool


在myappconsole.jar ?myappadmin.jar的manifest文g中分别注明各自的 Main Class


Package Versioning

完成发布后,如果使用者想了解 Q哪些代码是谁的Q目前是什么版本?使用什么版本的cdQ解决的Ҏ很多 Qmanifest提供了一个较好的ҎQ你可以在manifest文g中描q每一个包的信息?

Java U承了实现说明与描述分离的原则,package 的描q?定义了package 是什么,实现说明 定义了谁提供了描q的实现Q描q和实现包含 名、版本号和提供者。要得到q些信息Q可以查看JVM的系l属性(使用 java.lang.System.getProperty() Q?


在manifest文g中,我可以ؓ每个package定义描述和实现版本,声明名字Qƈ加入描述属性和实现属性,q些属性是

Specification-Title
Specification-Version
Specification-Vendor
Implementation-Title
Implementation-Version
Implementation-Vendor

当要提供一个类库或~程接口Ӟ描述信息昑־是很重要Q见以下范例Q?

Manifest-Version: 1.0
Created-By: JDJ example
Class-Path: mail.jar activation.jar

Name: com/example/myapp/
Specification-Title: MyApp
Specification-Version: 2.4
Specification-Vendor: example.com
Implementation-Title: com.example.myapp
Implementation-Version: 2002-03-05-A
Implementation-Vendor: example.com


Package Version 查询
在manifest文g中加入package描述后,可以用Java提供的java.lang.Package classq行Package 的信息查询,q里列D3个最基本的获取package object的方?

1.Package.getPackages():q回pȝ中所有定义的package列表
2.Package.getPackage(String packagename):按名q回package
3.Class.getPackage():q回l定class所在的package

使用者这Ҏ可以动态的获取package信息.
需要注意的是如果给定的package中没有class被加?则也无法获得package 对象

Manifest 技?
L以Manifest-Version属性开?

每行最?2个字W,如果过的化Q采用箋?

认每行都以回Rl束Q否则改行将会被忽略

如果Class-Path 中的存在路径Q?/"分隔目录Q与q_无关

使用I分隔d性和package属?

使用"/"而不?."来分隔package 和class ,比如 com/example/myapp/

class 要以.classl尾Qpackage 要以 / l尾

mag.javadigest.net ~译 英文原文

译 yife

引用Qhttp://www.jdon.com/jivejdon/forum/messageList.shtml?thread=15361&message=6994399


]]>
应用displaytag1.1 完成大数据量分页昄的例?/title><link>http://www.tkk7.com/huanghuizz/articles/78335.html</link><dc:creator>七匹?/dc:creator><author>七匹?/author><pubDate>Tue, 31 Oct 2006 09:53:00 GMT</pubDate><guid>http://www.tkk7.com/huanghuizz/articles/78335.html</guid><wfw:comment>http://www.tkk7.com/huanghuizz/comments/78335.html</wfw:comment><comments>http://www.tkk7.com/huanghuizz/articles/78335.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/huanghuizz/comments/commentRss/78335.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/huanghuizz/services/trackbacks/78335.html</trackback:ping><description><![CDATA[ <p>应用displaytag在struts中完成大数据量分|C,Oracle数据?/p> <p> </p> <p>JSP文gQ?/p> <p> </p> <div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 95%;"> <div> <img id="_2_54_Open_Image" onclick="this.style.display='none'; document.getElementById('_2_54_Open_Text').style.display='none'; document.getElementById('_2_54_Closed_Image').style.display='inline'; document.getElementById('_2_54_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="_2_54_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_2_54_Closed_Text').style.display='none'; document.getElementById('_2_54_Open_Image').style.display='inline'; document.getElementById('_2_54_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" /> <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 0);"><%</span> <span id="_2_54_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_2_54_Open_Text"> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">@ taglib uri</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">=</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">"</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">/WEB-INF/displaytag.tld</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">"</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);"> prefix</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">=</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">"</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">disp</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">"</span> <span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);"> </span> </span> <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 0);">%></span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /> </span> <span style="color: rgb(0, 0, 255);"><</span> <span style="color: rgb(128, 0, 0);">disp:table </span> <span style="color: rgb(255, 0, 0);">name</span> <span style="color: rgb(0, 0, 255);">="resultList"</span> <span style="color: rgb(255, 0, 0);"> export</span> <span style="color: rgb(0, 0, 255);">="true"</span> <span style="color: rgb(255, 0, 0);"> pagesize</span> <span style="color: rgb(0, 0, 255);">="100"</span> <span style="color: rgb(255, 0, 0);"> requestURI</span> <span style="color: rgb(0, 0, 255);">="logQueryAction.do"</span> <span style="color: rgb(255, 0, 0);"> sort</span> <span style="color: rgb(0, 0, 255);">="external"</span> <span style="color: rgb(255, 0, 0);"> id</span> <span style="color: rgb(0, 0, 255);">="element"</span> <span style="color: rgb(255, 0, 0);"> partialList</span> <span style="color: rgb(0, 0, 255);">="true"</span> <span style="color: rgb(255, 0, 0);"> size</span> <span style="color: rgb(0, 0, 255);">="resultSize"</span> <span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />          </span> <span style="color: rgb(0, 0, 255);"><</span> <span style="color: rgb(128, 0, 0);">disp:column </span> <span style="color: rgb(255, 0, 0);">property</span> <span style="color: rgb(0, 0, 255);">="operdate"</span> <span style="color: rgb(255, 0, 0);"> title</span> <span style="color: rgb(0, 0, 255);">="操作旉"</span> <span style="color: rgb(255, 0, 0);"> </span> <span style="color: rgb(0, 0, 255);">></</span> <span style="color: rgb(128, 0, 0);">disp:column</span> <span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />          </span> <span style="color: rgb(0, 0, 255);"><</span> <span style="color: rgb(128, 0, 0);">disp:column </span> <span style="color: rgb(255, 0, 0);">property</span> <span style="color: rgb(0, 0, 255);">="pername"</span> <span style="color: rgb(255, 0, 0);"> title</span> <span style="color: rgb(0, 0, 255);">="操作人员"</span> <span style="color: rgb(255, 0, 0);"> </span> <span style="color: rgb(0, 0, 255);">></</span> <span style="color: rgb(128, 0, 0);">disp:column</span> <span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />          </span> <span style="color: rgb(0, 0, 255);"><</span> <span style="color: rgb(128, 0, 0);">disp:column </span> <span style="color: rgb(255, 0, 0);">property</span> <span style="color: rgb(0, 0, 255);">="opertype"</span> <span style="color: rgb(255, 0, 0);"> title</span> <span style="color: rgb(0, 0, 255);">="操作cd"</span> <span style="color: rgb(255, 0, 0);"> </span> <span style="color: rgb(0, 0, 255);">></</span> <span style="color: rgb(128, 0, 0);">disp:column</span> <span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /> </span> <span style="color: rgb(0, 0, 255);"></</span> <span style="color: rgb(128, 0, 0);">disp:table</span> <span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 0);"> <br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /></span> </div> </div> <p> </p> <p>name="resultList" 记录集存在session或者request中的键?br />export="true" 是否昄导出选项<br />pagesize="100" 每页昄100条数?br />requestURI="logQueryAction.do"  struts中action的名Uͼ如果记录,可以直接分页<br />sort="external"  外部排序<br />id="element"   表格id|用于E序得相关的参数<br />partialList="true"  分段从数据库中读数据<br />size="resultSize"  记录的L敎ͼ用于计算总页?/p> <p> </p> <p>struts action:</p> <p> </p> <div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 95%;"> <div> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /> <span style="color: rgb(0, 0, 0);">String pageIndexName </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);"> org.displaytag.util.ParamEncoder(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">element</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">).encodeParameterName(org.displaytag.tags.TableTagParameters.PARAMETER_PAGE);   // |的参数名<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);"> pageSize </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">100</span> <span style="color: rgb(0, 0, 0);">;   //每页昄的条?br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);"> pageIndex </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> GenericValidator.isBlankOrNull(request.getParameter(pageIndexName))</span> <span style="color: rgb(0, 0, 0);">?</span> <span style="color: rgb(0, 0, 0);">0</span> <span style="color: rgb(0, 0, 0);">:(Integer.parseInt(request.getParameter(pageIndexName)) </span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">);  //当前|<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />String sqlCount </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">select count(*)  from user_log a </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">;  //用于l计总记录数的sql语句<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        String sql </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> select * from (select rownum as rid, t1.* from (select b.pername as pername,to_char(a.operdate,'yyyy-mm-dd hh24:mi:ss') as operdate,</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />                </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> decode(a.opertype,'D','删除','M','修改','其他') as opertype, a.hphm as hphm from user_log a, </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />                </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> (select asuser.userid as userid,nvl(asempmsg.pername,asuser.loginname) as pername from asuser,ASEMPMSG where asuser.perid=ASEMPMSG.perid(+)) b</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />                </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> where a.userid=b.userid </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">;   //查询语句</span> </div> <div> <span style="color: rgb(0, 0, 0);">            //构造查询条?br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        StringBuffer sb </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);"> StringBuffer();<br /><img id="_930_1025_Open_Image" onclick="this.style.display='none'; document.getElementById('_930_1025_Open_Text').style.display='none'; document.getElementById('_930_1025_Closed_Image').style.display='inline'; document.getElementById('_930_1025_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_930_1025_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_930_1025_Closed_Text').style.display='none'; document.getElementById('_930_1025_Open_Image').style.display='inline'; document.getElementById('_930_1025_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(logQueryForm.getCzrqStart()</span> <span style="color: rgb(0, 0, 0);">!=</span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">&&</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">!</span> <span style="color: rgb(0, 0, 0);">""</span> <span style="color: rgb(0, 0, 0);">.equals(logQueryForm.getCzrqStart()))</span> <span id="_930_1025_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_930_1025_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            sb.append(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> and a.operdate > to_date('</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">logQueryForm.getCzrqStart()</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">','yyyy-mm-dd')</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">);<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span> </span> <span style="color: rgb(0, 0, 0);"> <br /> <img id="_1105_1199_Open_Image" onclick="this.style.display='none'; document.getElementById('_1105_1199_Open_Text').style.display='none'; document.getElementById('_1105_1199_Closed_Image').style.display='inline'; document.getElementById('_1105_1199_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="_1105_1199_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_1105_1199_Closed_Text').style.display='none'; document.getElementById('_1105_1199_Open_Image').style.display='inline'; document.getElementById('_1105_1199_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(logQueryForm.getCzrqEnd()</span> <span style="color: rgb(0, 0, 0);">!=</span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">&&</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">!</span> <span style="color: rgb(0, 0, 0);">""</span> <span style="color: rgb(0, 0, 0);">.equals(logQueryForm.getCzrqEnd()))</span> <span id="_1105_1199_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_1105_1199_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            sb.append(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> and a.operdate <= to_date('</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">logQueryForm.getCzrqEnd()</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">','yyyy-mm-dd')</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">);<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span> </span> <span style="color: rgb(0, 0, 0);"> <br /> <img id="_1273_1341_Open_Image" onclick="this.style.display='none'; document.getElementById('_1273_1341_Open_Text').style.display='none'; document.getElementById('_1273_1341_Closed_Image').style.display='inline'; document.getElementById('_1273_1341_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="_1273_1341_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_1273_1341_Closed_Text').style.display='none'; document.getElementById('_1273_1341_Open_Image').style.display='inline'; document.getElementById('_1273_1341_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(logQueryForm.getCzlx()</span> <span style="color: rgb(0, 0, 0);">!=</span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">&&</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">!</span> <span style="color: rgb(0, 0, 0);">""</span> <span style="color: rgb(0, 0, 0);">.equals(logQueryForm.getCzlx()))</span> <span id="_1273_1341_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_1273_1341_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            sb.append(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> and a.opertype = '</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">logQueryForm.getCzlx()</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">'</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">);<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span> </span> <span style="color: rgb(0, 0, 0);"> <br /> <img id="_1415_1481_Open_Image" onclick="this.style.display='none'; document.getElementById('_1415_1481_Open_Text').style.display='none'; document.getElementById('_1415_1481_Closed_Image').style.display='inline'; document.getElementById('_1415_1481_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="_1415_1481_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_1415_1481_Closed_Text').style.display='none'; document.getElementById('_1415_1481_Open_Image').style.display='inline'; document.getElementById('_1415_1481_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(logQueryForm.getCzry()</span> <span style="color: rgb(0, 0, 0);">!=</span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">&&</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">!</span> <span style="color: rgb(0, 0, 0);">""</span> <span style="color: rgb(0, 0, 0);">.equals(logQueryForm.getCzry()))</span> <span id="_1415_1481_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_1415_1481_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            sb.append(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> and a.userid = '</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">logQueryForm.getCzry()</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">'</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">);<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span> </span> <span style="color: rgb(0, 0, 0);"> <br /> <img id="_1555_1624_Open_Image" onclick="this.style.display='none'; document.getElementById('_1555_1624_Open_Text').style.display='none'; document.getElementById('_1555_1624_Closed_Image').style.display='inline'; document.getElementById('_1555_1624_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="_1555_1624_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_1555_1624_Closed_Text').style.display='none'; document.getElementById('_1555_1624_Open_Image').style.display='inline'; document.getElementById('_1555_1624_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />     </span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        sqlCount </span> <span style="color: rgb(0, 0, 0);">+=</span> <span style="color: rgb(0, 0, 0);"> sb.toString();<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        sql </span> <span style="color: rgb(0, 0, 0);">+=</span> <span style="color: rgb(0, 0, 0);"> sb.toString()</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> order by a.operdate desc) t1 where rownum<=</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />                        </span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);"> (pageIndex </span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">) </span> <span style="color: rgb(0, 0, 0);">*</span> <span style="color: rgb(0, 0, 0);"> pageSize </span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> ) t2 where t2.rid></span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);"> pageIndex </span> <span style="color: rgb(0, 0, 0);">*</span> <span style="color: rgb(0, 0, 0);"> pageSize;  //分页d语句<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        <br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">System.out.println(sb.toString());</span> <span style="color: rgb(0, 128, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /> </span> <span style="color: rgb(0, 0, 0);">        DBBean db </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);"> DBBean();<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        ResultSet rs </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);">;<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        PreparedStatement prep </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> </span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);">;<br /><img id="_1938_2211_Open_Image" onclick="this.style.display='none'; document.getElementById('_1938_2211_Open_Text').style.display='none'; document.getElementById('_1938_2211_Closed_Image').style.display='inline'; document.getElementById('_1938_2211_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_1938_2211_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_1938_2211_Closed_Text').style.display='none'; document.getElementById('_1938_2211_Open_Image').style.display='inline'; document.getElementById('_1938_2211_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">try</span> <span id="_1938_2211_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_1938_2211_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            List resultList </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> db.getResultList(sql);   //ResultSet保存在List里返?br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            request.setAttribute(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">resultList</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">,resultList);  //把结果存入request<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            prep </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> db.getConnection().prepareStatement(sqlCount);    <br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            rs </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"> prep.executeQuery();<br /><img id="_2136_2207_Open_Image" onclick="this.style.display='none'; document.getElementById('_2136_2207_Open_Text').style.display='none'; document.getElementById('_2136_2207_Closed_Image').style.display='inline'; document.getElementById('_2136_2207_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="_2136_2207_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_2136_2207_Closed_Text').style.display='none'; document.getElementById('_2136_2207_Open_Image').style.display='inline'; document.getElementById('_2136_2207_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(rs.next())</span> <span id="_2136_2207_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_2136_2207_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />                request.setAttribute(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">resultSize</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);"> Integer(rs.getInt(</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">)));     //总记录数保存成Intger实例保存在request?br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span> </span> <span style="color: rgb(0, 0, 0);"> <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span> </span> <span style="color: rgb(0, 0, 0);"> <br /> <img id="_2234_2263_Open_Image" onclick="this.style.display='none'; document.getElementById('_2234_2263_Open_Text').style.display='none'; document.getElementById('_2234_2263_Closed_Image').style.display='inline'; document.getElementById('_2234_2263_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="_2234_2263_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_2234_2263_Closed_Text').style.display='none'; document.getElementById('_2234_2263_Open_Image').style.display='inline'; document.getElementById('_2234_2263_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">catch</span> <span style="color: rgb(0, 0, 0);">(Exception ex)</span> <span id="_2234_2263_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_2234_2263_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />            ex.printStackTrace();<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span> </span> <span style="color: rgb(0, 0, 0);"> <br /> <img id="_2274_2327_Open_Image" onclick="this.style.display='none'; document.getElementById('_2274_2327_Open_Text').style.display='none'; document.getElementById('_2274_2327_Closed_Image').style.display='inline'; document.getElementById('_2274_2327_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="_2274_2327_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_2274_2327_Closed_Text').style.display='none'; document.getElementById('_2274_2327_Open_Image').style.display='inline'; document.getElementById('_2274_2327_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />        </span> <span style="color: rgb(0, 0, 255);">finally</span> <span id="_2274_2327_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_2274_2327_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img id="_2291_2322_Open_Image" onclick="this.style.display='none'; document.getElementById('_2291_2322_Open_Text').style.display='none'; document.getElementById('_2291_2322_Closed_Image').style.display='inline'; document.getElementById('_2291_2322_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="_2291_2322_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_2291_2322_Closed_Text').style.display='none'; document.getElementById('_2291_2322_Open_Image').style.display='inline'; document.getElementById('_2291_2322_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(db</span> <span style="color: rgb(0, 0, 0);">!=</span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);">)</span> <span id="_2291_2322_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span> <span id="_2291_2322_Open_Text"> <span style="color: rgb(0, 0, 0);">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />                db.closeConnection();    //关闭q接<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span> </span> <span style="color: rgb(0, 0, 0);"> <br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span> </span> </div> </div> <p> </p> <p>其中的页面导航是英文的,只要修改org.displaytag.properties.TableTag.properties配置文g可以把英文Ҏ中文。同时还可以指定导出文g的类型以及文件名?/p> <div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; width: 95%;"> <div> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /> <span style="color: rgb(0, 0, 0);">export.excel</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">true<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />export.excel.label</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);"><span class</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">export excel</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">>Excel </span><br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />export.excel.include_header</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">true<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />export.excel.filename</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">export.xls</span> </div> </div> <p>如果不指定文件名Q在点击导出excel的时候,׃在ieH口中打开excel文g。很烦hQ?br />指定文g名后可以选择保存和打开了?/p> <div align="center"> <script type="text/javascript"> <!--google_ad_client = "pub-9648238652058580";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as_rimg";google_cpa_choice = "CAAQiYaYhAIaCJ2wcuQYTrQ_KOm293M";google_ad_channel = "";//--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <iframe name="google_ads_frame" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-9648238652058580&dt=1162260842406&lmt=1162260832&prev_fmts=125x125_as&format=180x60&output=html&url=http%3A%2F%2Fblog.csdn.net%2Flveyo%2Farchive%2F2006%2F08%2F16%2F1076047.aspx&ref=http%3A%2F%2Ftag.csdn.net%2FArticle%2Fabe762e2-9bc7-4287-8938-f3828bd1af68.html&cc=22&u_h=768&u_w=1024&u_ah=690&u_aw=1024&u_cd=32&u_tz=480&u_his=1&u_java=true&u_nplug=17&u_nmime=52" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" frameborder="0" height="60" scrolling="no" width="180"> </iframe> </div> <br /> <br /> <p id="TBPingURL">Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1076047</p> <img src ="http://www.tkk7.com/huanghuizz/aggbug/78335.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/huanghuizz/" target="_blank">七匹?/a> 2006-10-31 17:53 <a href="http://www.tkk7.com/huanghuizz/articles/78335.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在JSP中应用FCKeditorhttp://www.tkk7.com/huanghuizz/articles/77947.html七匹?/dc:creator>七匹?/author>Sun, 29 Oct 2006 16:16:00 GMThttp://www.tkk7.com/huanghuizz/articles/77947.htmlhttp://www.tkk7.com/huanghuizz/comments/77947.htmlhttp://www.tkk7.com/huanghuizz/articles/77947.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/77947.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/77947.html1. FCKeditor2.1.1解压~到目的根目录下,目录l构为:\目名\FCKeditor\ Q然后将FCKeditor-2.3.zipQjavaQ压~包中\web\WEB-INF\lib\目录下的两个jar文g拷到目的\WEB-INF\lib\目录下?/p>

2. FCKeditor-2.3.zip压羃包中\web\WEB-INF\目录下的web.xml文g合ƈ到项目的\WEB-INF\目录下的web.xml文g中?/p>

3. 修改合ƈ后的web.xml文gQ将名ؓSimpleUploader的Servlet的enabled参数值改为trueQ以允许上传功能QConnector Servlet的baseDir参数值用于设|上传文件存攄位置?/p>

4. 上面两个servlet的映分别ؓQ?editor/filemanager/browser/default/connectors/jsp/connector?editor/filemanager/upload/simpleuploaderQ因为我的FCKeditor是放到\目名\FCKeditor\目录下,所以需要在两个映射前面加上/FCKeditorQ即改ؓ/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector?FCKeditor/editor/filemanager/upload/simpleuploader?/p>

5. 采用Taglib在jsp中添加如下代码创建在U编辑器Q?/p>

    在页面的剙加入?@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="FCK" %?/p>

    在适当的位|加入下面代?/p>

  〈FCK:editor id="infoContent" basePath="/CM/FCKeditor/"
              width="522"
              height="300"
              skinPath="/CM/FCKeditor/editor/skins/silver/"
              defaultLanguage="zh-cn"
              tabSpaces="8"
              toolbarSet="CM"
              imageBrowserURL="/CM/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
              linkBrowserURL="/CM/FCKeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
              flashBrowserURL="/CM/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
              imageUploadURL="/CM/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image"
              linkUploadURL="/CM/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File"
              flashUploadURL="/CM/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash"?br />              误入内?br />  ?FCK:editor?/fck:editor>

    注意/CM/Qؓ目名,不用修改web.xml文g?/p>

6. l过上面步骤可以在jsp中用FCKeditor了?/p>

===================================================================

另外Q如果用WebLogicQ需要将FCKeditor-2.3.zip压羃包中src目录下的FCKeditor.tld文g提取出来Q比如将其放到WEB-INF/tlds/目录下,然后jsp中的taglib语句修改为如下所C,可以正怋用了Q?/p>

<%@ taglib uri="/WEB-INF/tlds/FCKeditor.tld" prefix="FCK" %>

三、配|?/b>

  FCKeditor 2.0的配|文件ؓFCKeditor\fckconfig.jsQ其中几个重要的配置目如下Q?br />
1、工h的设|?br />
  默认情况下,FCKeditor会调用如下的工具栏按钮,大家可以Ҏ自己的需要进行增减。需要注意的是,2.0版与1.6版的按钮q不完全相同Q有些按钮以及删除或者改名了?br />
//##
//## Toolbar Buttons Sets
//##
FCKConfig.ToolbarSets["Default"] = [
       ['Source','-','Save','NewPage','Preview'],
       ['Cut','Copy','Paste','PasteText','PasteWord','-','Print'],
       ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
       ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
       ['OrderedList','UnorderedList','-','Outdent','Indent'],
       ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
       ['Link','Unlink'],
       ['Image','Table','Rule','SpecialChar','Smiley'],
       ['Style','FontFormat','FontName','FontSize'],
       ['TextColor','BGColor'],
       ['About']
] ;

2、简体中文设|?br />
~辑edit/lang/fcklanguagemanager.js

下面语?br />
FCKLanguageManager.AvailableLanguages =
{
 'ar'  : 'Arabic',
 'bs'  : 'Bosnian',
 'ca'  : 'Catalan',
 'en'  : 'English',
 'es'  : 'Spanish',
 'et'  : 'Estonian',
 'fi'  : 'Finnish',
 'fr'  : 'French',
 'gr'  : 'Greek',
 'he'  : 'Hebrew',
 'hr'  : 'Croatian',
 'it'  : 'Italian',
 'ko'  : 'Korean',
 'lt'  : 'Lithuanian',
 'no'  : 'Norwegian',
 'pl'  : 'Polish',
 'sr'  : 'Serbian (Cyrillic)',
 'sr-latn' : 'Serbian (Latin)',
 'sv'  : 'Swedish'
}

d一?'zh-cn'    : 'Chinese' 从而变?br />
FCKLanguageManager.AvailableLanguages =
{
 'ar'  : 'Arabic',
 'bs'  : 'Bosnian',
 'ca'  : 'Catalan',
 'en'  : 'English',
 'es'  : 'Spanish',
 'et'  : 'Estonian',
 'fi'  : 'Finnish',
 'fr'  : 'French',
 'gr'  : 'Greek',
 'he'  : 'Hebrew',
 'hr'  : 'Croatian',
 'it'  : 'Italian',
 'ko'  : 'Korean',
 'lt'  : 'Lithuanian',
 'no'  : 'Norwegian',
 'pl'  : 'Polish',
 'sr'  : 'Serbian (Cyrillic)',
 'sr-latn' : 'Serbian (Latin)',
 'sv'  : 'Swedish',
 'zh-cn'     : 'Chinese'
}

  然后到这?a >http://www.shaof.com/download/zh-cn.js下蝲汉化好的zh-cn.js保存到editor/lang目录下即可?/div>

]]>log4j 学习http://www.tkk7.com/huanghuizz/articles/72590.html七匹?/dc:creator>七匹?/author>Thu, 28 Sep 2006 07:31:00 GMThttp://www.tkk7.com/huanghuizz/articles/72590.htmlhttp://www.tkk7.com/huanghuizz/comments/72590.htmlhttp://www.tkk7.com/huanghuizz/articles/72590.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/72590.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/72590.html

]]>
命名规则http://www.tkk7.com/huanghuizz/articles/71498.html七匹?/dc:creator>七匹?/author>Sat, 23 Sep 2006 15:18:00 GMThttp://www.tkk7.com/huanghuizz/articles/71498.htmlhttp://www.tkk7.com/huanghuizz/comments/71498.htmlhttp://www.tkk7.com/huanghuizz/articles/71498.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/71498.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/71498.html 比较著名的命名规则当推Microsoft公司的“匈牙利”法Q该命名规则的主要思想是“在变量和函数名中加入前~以增qh们对E序的理解”。例如所有的字符变量均以ch为前~Q若是指针变量则q加前缀p。如果一个变量由ppch开_则表明它是指向字W指针的指针?br />
“匈牙利”法最大的~点是烦琐,例如

int i, j, k;

float x, y, z;

倘若采用“匈牙利”命名规则,则应当写?br />
int iI, iJ, ik; // 前缀 i表示intcd

float fX, fY, fZ; // 前缀 f表示floatcd

如此烦琐的程序会让绝大多数程序员无法忍受?br />
据考察Q没有一U命名规则可以让所有的E序员赞同,E序设计教科书一般都不指定命名规则。命名规则对软g产品而言q不是“成败悠关”的事,我们不要化太多精力试囑֏明世界上最好的命名规则Q而应当制定一Uo大多数项目成员满意的命名规则Qƈ在项目中贯彻实施?br />
3.1 共性规?br />本节的共性规则是被大多数E序员采U的Q我们应当在遵@q些共性规则的前提下,再扩充特定的规则Q如3.2节?br />

l 【规?-1-1】标识符应当直观且可以拼读,可望文知意,不必q行“解码”?br />
标识W最好采用英文单词或其组合,便于记忆和阅诅R切忌用汉语拼x命名。程序中的英文单词一般不会太复杂Q用词应当准。例如不要把CurrentValue写成NowValue?br />

l 【规?-1-2】标识符的长度应当符合“min-length && max-information”原则?br />
几十q前老ANSI C规定名字不准过6个字W,C的C++/C不再有此限制。一般来_长名字能更好地表辑֐义,所以函数名、变量名、类名长辑֍几个字符不为怪。那么名字是否越长约好?不见? 例如变量名maxval比maxValueUntilOverflow好用。单字符的名字也是有用的Q常见的如i,j,k,m,n,x,y,z{,它们通常可用作函数内的局部变量?br />

l 【规?-1-3】命名规则尽量与所采用的操作系l或开发工L风格保持一致?br />
例如Windows应用E序的标识符通常采用“大写”؜排的方式Q如AddChild。而Unix应用E序的标识符通常采用“小写加下划U쀝的方式Q如add_child。别把这两类风格混在一L?br />

l 【规?-1-4】程序中不要出现仅靠大小写区分的怼的标识符?br />
例如Q?br />
int x, X; // 变量x ?X Ҏh

void foo(int x); // 函数foo 与FOOҎh

void FOO(float x);


l 【规?-1-5】程序中不要出现标识W完全相同的局部变量和全局变量Q尽两者的作用域不同而不会发生语法错误,但会使h误解?br />

l 【规?-1-6】变量的名字应当使用“名词”或者“Ş容词Q名词”?br />
例如Q?br />
float value;

float oldValue;

float newValue;


l 【规?-1-7】全局函数的名字应当用“动词”或者“动词+名词”(动宾词组Q。类的成员函数应当只使用“动词”,被省略掉的名词就是对象本w?br />
例如Q?br />
DrawBox(); // 全局函数

box->Draw(); // cȝ成员函数


l 【规?-1-8】用正确的反义词l命名具有互斥意义的变量或相反动作的函数{?br />
例如Q?br />
int minValue;

int maxValue;


int SetValue(?;

int GetValue(?;


2 【徏?-1-1】尽量避免名字中出现数字~号Q如Value1,Value2{,除非逻辑上的需要编受这是ؓ了防止程序员hQ不肯ؓ命名动脑{而导致生无意义的名字(因ؓ用数字编h省事Q?br />
3.2 单的Windows应用E序命名规则
作者对“匈牙利”命名规则做了合理的化,下述的命名规则简单易用,比较适合于Windows应用软g的开发?br />

l 【规?-2-1】类名和函数名用大写字母开头的单词l合而成?br />
例如Q?br />
class Node; // cd

class LeafNode; // cd

void Draw(void); // 函数?br />
void SetValue(int value); // 函数?br />

l 【规?-2-2】变量和参数用小写字母开头的单词l合而成?br />
例如Q?br />
BOOL flag;

int drawMode;


l 【规?-2-3】常量全用大写的字母Q用下划U分割单词?br />
例如Q?br />
const int MAX = 100;

const int MAX_LENGTH = 100;


l 【规?-2-4】静态变量加前缀s_Q表CstaticQ?br />
例如Q?br />
void Init(?

{

static int s_initValue; // 静态变?br />
?br />
}


l 【规?-2-5】如果不得已需要全局变量Q则使全局变量加前~g_Q表CglobalQ?br />
例如Q?br />
int g_howManyPeople; // 全局变量

int g_howMuchMoney; // 全局变量


l 【规?-2-6】类的数据成员加前缀m_Q表CmemberQ,q样可以避免数据成员与成员函数的参数同名?br />
例如Q?br />
void Object::SetValue(int width, int height)

{

m_width = width;

m_height = height;

}


l 【规?-2-7】ؓ了防止某一软g库中的一些标识符和其它Y件库中的冲突Q可以ؓ各种标识W加上能反映软g性质的前~。例如三l图形标准OpenGL的所有库函数均以gl开_所有常量(或宏定义Q均以GL开头?br />



]]>
获得客户端的iphttp://www.tkk7.com/huanghuizz/articles/70813.html七匹?/dc:creator>七匹?/author>Wed, 20 Sep 2006 07:27:00 GMThttp://www.tkk7.com/huanghuizz/articles/70813.htmlhttp://www.tkk7.com/huanghuizz/comments/70813.htmlhttp://www.tkk7.com/huanghuizz/articles/70813.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/70813.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/70813.html在IIS+Weblogic整合pȝ中,像移动网关一Piisforwardq个ISAPIqo器也会对request对象q行再包装,附加一些WLS要用的头信息。这U情况下Q直接用request.getRemoteAddr()是无法取到真正的客户IP的?br />
实际的iisforward附加头如下:

WL-Proxy-Client-IP=211.161.1.239
Proxy-Client-IP=211.161.1.239
X-Forwarded-For=211.161.1.239
WL-Proxy-Client-Keysize=
WL-Proxy-Client-Secretkeysize=
X-WebLogic-Request-ClusterInfo=true
X-WebLogic-KeepAliveSecs=30
X-WebLogic-Force-JVMID=-327089098
WL-Proxy-SSL=false
lgQ正作法如下:
public String getIpAddr(HttpServletRequest request) {
    String ip=request.getHeader("X-Forwarded-For");
    if(ip == null || ip.length() == 0) {
        ip=request.getHeader("Proxy-Client-IP");
    }
    if(ip == null || ip.length() == 0) {
        ip=request.getHeader("WL-Proxy-Client-IP");
    }
    if(ip == null || ip.length() == 0) {
        ip=request.getRemoteAddr();
    }
    return ip;
}
如此一来,可适应各种情况Q包括通过Ud|关讉KQ会附加X-Forwarded-ForQ。通过q个单例子可以看出封装和抽象的重要性?

]]>
HibernateE序性能优化的考虑要点http://www.tkk7.com/huanghuizz/articles/70214.html七匹?/dc:creator>七匹?/author>Mon, 18 Sep 2006 01:32:00 GMThttp://www.tkk7.com/huanghuizz/articles/70214.htmlhttp://www.tkk7.com/huanghuizz/comments/70214.htmlhttp://www.tkk7.com/huanghuizz/articles/70214.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/70214.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/70214.html  初用HIBERNATE的h也许都遇到过性能问题Q实现同一功能Q用HIBERNATE与用JDBC性能相差十几倍很正常Q如果不及早调整Q很可能影响整个目的进度?/p>

  大体上,对于HIBERNATE性能调优的主要考虑点如?

  Ø 数据库设计调?/p>

  Ø HQL优化

  Ø API的正?如根据不同的业务cd选用不同的集合及查询API)

  Ø 主配|参?日志Q查询缓存,fetch_size, batch_size{?

  Ø 映射文g优化(ID生成{略Q二U缓存,延迟加蝲Q关联优?

  Ø 一U缓存的理

  Ø 针对二~存Q还有许多特有的{略

  Ø 事务控制{略?/p>

  1?数据库设?/p>

  a) 降低兌的复杂?/p>

  b) 量不用联合主?/p>

  c) ID的生成机Ӟ不同的数据库所提供的机制ƈ不完全一?/p>

  d) 适当的冗余数据,不过分追求高范式

  2?HQL优化

  HQL如果抛开它同HIBERNATE本n一些缓存机制的兌QHQL的优化技巧同普通的SQL优化技巧一P可以很容易在|上扑ֈ一些经验之谈?/p>

  3?主配|?/p>

  a) 查询~存Q同下面讲的~存不太一P它是针对HQL语句的缓存,卛_全一L语句再次执行时可以利用缓存数据。但是,查询~存在一个交易系l?数据变更频繁Q查询条件相同的机率q不?中可能会起反作用:它会白白耗费大量的系l资源但却难以派上用场?/p>

  b) fetch_sizeQ同JDBC的相兛_C用类|参数q不是越大越好,而应Ҏ业务特征去设|?/p>

  c) batch_size同上?/p>

  d) 生pȝ中,切记要关掉SQL语句打印?/p>

  4?~存

  a) 数据库~存:q~存是最高效和安全的Q但不同的数据库可管理的层次q不一P比如Q在ORACLE中,可以在徏表时指定整个表|于~存当中?/p>

  b) SESSION~存:在一个HIBERNATE SESSION有效Q这U缓存的可干预性不强,大多于HIBERNATE自动理Q但它提供清除缓存的ҎQ这在大扚w增加/更新操作是有效的。比如,同时增加十万条记录,按常规方式进行,很可能会发现OutofMemeroy的异常,q时可能需要手动清除这一U缓?Session.evict以及Session.clear

  c) 应用~存:在一个SESSIONFACTORY中有效,因此也是优化的重中之重,因此Q各cȝ略也考虑的较多,在将数据攑օq一U缓存之前,需要考虑一些前提条?

  i. 数据不会被第三方修改(比如Q是否有另一个应用也在修改这些数?)

  ii. 数据不会太大

  iii. 数据不会频繁更新(否则使用CACHE可能适得其反)

  iv. 数据会被频繁查询

  v. 数据不是关键数据(如涉及钱Q安全等斚w的问??/p>

  ~存有几UŞ式,可以在映文件中配置:read-only(只读Q适用于很变更的静态数?历史数据)Qnonstrict-read-writeQread-write(比较普遍的Ş式,效率一?Qtransactional(JTA中,且支持的~存产品较少)

  d) 分布式缓?同c)的配|一P只是~存产品的选用不同Q在目前的HIBERNATE中可供选择的不多,oscache, jboss cacheQ目前的大多数项目,对它们的用于集群的?特别是关键交易系l?都持保守态度。在集群环境中,只利用数据库U的~存是最安全的?/p>

  5?延迟加蝲

  a) 实体延迟加蝲:通过使用动态代理实?/p>

  b) 集合延迟加蝲:通过实现自有的SET/LISTQHIBERNATE提供了这斚w的支?/p>

  c) 属性gq加?

  6?Ҏ选用

  a) 完成同样一件事QHIBERNATE提供了可供选择的一些方式,但具体用什么方式,可能用性能/代码都会有媄响。显C,一ơ返回十万条记录(List/Set/Bag/Map{?q行处理Q很可能D内存不够的问题,而如果用Z游标(ScrollableResults)或Iterator的结果集Q则不存在这L问题?/p>

  b) Session的load/getҎQ前者会使用二~存Q而后者则不用?/p>

  c) Query和list/iteratorQ如果去仔细研究一下它们,你可能会发现很多有意思的情况Q二者主要区?如果使用了SpringQ在HibernateTemplate中对应find,iteratorҎ):

  i. list只能利用查询~存(但在交易pȝ中查询缓存作用不?Q无法利用二U缓存中的单个实体,但list查出的对象会写入二~存Q但它一般只生成较少的执行SQL语句Q很多情况就是一?无关??/p>

  ii. iterator则可以利用二U缓存,对于一条查询语句,它会先从数据库中扑և所有符合条件的记录的IDQ再通过IDȝ存找Q对于缓存中没有的记录,再构造语句从数据库中查出Q因此很Ҏ知道Q如果缓存中没有MW合条g的记录,使用iterator会生N+1条SQL语句(N为符合条件的记录?

  iii. 通过iteratorQ配合缓存管理APIQ在量数据查询中可以很好的解决内存问题Q如:

  while(it.hasNext()){

  YouObject object = (YouObject)it.next();

  session.evict(youObject);

  sessionFactory.evice(YouObject.class, youObject.getId());

  }

  如果用listҎQ很可能出OutofMemory错误了?/p>

  iv. 通过上面的说明,我想你应该知道如何去使用q两个方法了?/p>

  7?集合的选用

  在HIBERNATE 3.1文档的?9.5. Understanding Collection performance”中有详l的说明?/p>

  8?事务控制

  事务斚wҎ能有媄响的主要包括:事务方式的选用Q事务隔ȝ别以及锁的选用

  a) 事务方式选用:如果不涉及多个事务管理器事务的话Q不需要用JTAQ只有JDBC的事务控制就可以?/p>

  b) 事务隔离U别:参见标准的SQL事务隔离U别

  c) 锁的选用:悲观?一般由具体的事务管理器实现)Q对于长事务效率低,但安全。乐观锁(一般在应用U别实现)Q如在HIBERNATE中可以定义VERSION字段Q显Ӟ如果有多个应用操作数据,且这些应用不是用同一U乐观锁机制Q则乐观锁会失效。因此,针对不同的数据应有不同的{略Q同前面许多情况一P很多时候我们是在效率与安全/准确性上找一个^衡点Q无论如何,优化都不是一个纯技术的问题Q你应该对你的应用和业务特征有够的了解?/p>

  9?扚w操作

  即是用JDBCQ在q行大批数据更新ӞBATCH与不使用BATCH有效率上也有很大的差别。我们可以通过讄batch_size来让其支持批量操作?/p>

  举个例子Q要扚w删除某表中的对象Q如“delete Account”,打出来的语句Q会发现HIBERNATE扑և了所有ACCOUNT的IDQ再q行删除Q这主要是ؓ了维护二U缓存,q样效率肯定高不了,在后l的版本中增加了bulk delete/updateQ但q也无法解决~存的维护问题。也是_׃有了二~存的维护问题,HIBERNATE的批量操作效率ƈ不尽如h?

  从前面许多要点可以看出,很多时候我们是在效率与安全/准确性上找一个^衡点Q无论如何,优化都不是一个纯技术的问题Q你应该对你的应用和业务特征有够的了解Q一般的Q优化方案应在架构设计期基本确定,否则可能D没必要的q工Q致佉K目g期,而作为架构师和项目经理,q要面对开发h员可能的抱怨,必竟Q我们对用户需求更改的控制力不大,但技?架构风险是应该在初期意识到ƈ制定好相关的对策?/p>

  q有一点要注意Q应用层的缓存只是锦上添花,永远不要把它当救命稻草,应用的根?数据库设计,法Q高效的操作语句Q恰当API的选择{?才是最重要的?/p>

]]>
谈cmshttp://www.tkk7.com/huanghuizz/articles/66838.html七匹?/dc:creator>七匹?/author>Thu, 31 Aug 2006 04:31:00 GMThttp://www.tkk7.com/huanghuizz/articles/66838.htmlhttp://www.tkk7.com/huanghuizz/comments/66838.htmlhttp://www.tkk7.com/huanghuizz/articles/66838.html#Feedback0http://www.tkk7.com/huanghuizz/comments/commentRss/66838.htmlhttp://www.tkk7.com/huanghuizz/services/trackbacks/66838.html
cms的大概的程如下Q?br />      面的制作(自定义规则,方便解析Q-Q-Q-》保存到数据库-Q-Q-Q》定时的发布Q发布时的解析,生成静态的面Q发布到哪个目录Q。?br />
   程大概如下Q但因ؓq和需求的不同数据库也不同的解析的方式也不同。本人才知道程Q具体还不清。请各位大虾指点好的书籍和好的方法?img src ="http://www.tkk7.com/huanghuizz/aggbug/66838.html" width = "1" height = "1" />

]]>
վ֩ģ壺 hƬ߹ۿ| ޾ƷѹۿƵ| ޹պƵ| ¸Ļ| ŷaԴ| ޹ۺ | һȫٸɫƬ| ޾ƷƵ| ƷרëƬ| ƵѹۿƵ| ޾Ʒר| aɫëƬ| ޵һվƵ| Ƶ| Ʒ߹ۿ| ͵޾Ʒ1ҳ| þþþþѹۿ| VAѾƷ| avר| ߾Ʒһ| ëƬ߹ۿַ| ߹ۿѲavƬ| ޱ뾫ƷAAAƬ| ޹Ʒþ66| ޵һƷպ߲| Ƶ| 99re6߾Ʒѹۿ| WWW޾Ʒþ鶹| ޾Ʒþþþþþ| 99þۺϾƷ | þAV| ˳Ƶ| ˾þƵ| һƵѹۿ| ޾ƷĻ| þþƷ77777| һŮ| ѳavӰ| 벻Ƶ߹ۿ| ѹۿŮˮƵ| Ƭѿ|