??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲欧美国产另类,亚洲一区二区久久久久久,www亚洲精品http://www.aygfsteel.com/qiyadeng/category/3460.htmlif(log.itWillForget()){ <br>&nbsp;&nbsp; log.blog("log4deng!"); <br> }<br> else if(log.isYourExperience){ <br>&nbsp;&nbsp; log.blog("log4deng!"); <br> }<br> ......zh-cnWed, 28 Feb 2007 00:39:16 GMTWed, 28 Feb 2007 00:39:16 GMT60Struts Checkbox radio怎么q行动态的选择http://www.aygfsteel.com/qiyadeng/articles/23776.htmlqiyadengqiyadengWed, 14 Dec 2005 02:19:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/23776.htmlhttp://www.aygfsteel.com/qiyadeng/comments/23776.htmlhttp://www.aygfsteel.com/qiyadeng/articles/23776.html#Feedback0http://www.aygfsteel.com/qiyadeng/comments/commentRss/23776.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/23776.html使用Struts的朋友,可能l常发现使用面的一些标{时候觉得不够得心应手。比如我们要设计一个用户修改得信息的界面,需要调Z些用L(fng)信息。不q的是,当页面中含有Checkbox或是radio的时候有没有惌怎么处理Q以前我也ؓ(f)q个苦恼Q不论坛上的h也发帖子问这个问题。最q看C两篇文章Q可以解册个问题。来自IBM developer:
http://www-128.ibm.com/developerworks/java/library/j-sr3.html
http://www-128.ibm.com/developerworks/java/library/j-sr4.html
multibox.bmpradio.bmp
先调单的说v吧,我们来实现动态的checkbox:
1、Form的设计:(x)我们q个例子有个String[] mountainsQ这个变量数l中包含很多的山的名?q有个数lString[] selectedMountains是默认选中的一些山Q像下面q样很简单?/P>

public class MultiboxForm extends ActionForm {
 
 private String[] selectedMountains = {"Everest","K2","Lhotse","Cho Oyu"};
 private String[] mountains ={"Everest","K2","Kangchenjunga","Lhotse","Makalu","Kangchenjunga South","Lhotse Middle","Kangchenjunga West","Lhotse Shar","Cho Oyu"};

 public String[] getMountains() {
  return mountains;
 }
 public void setMountains(String[] mountains) {
  this.mountains = mountains;
 }
 public String[] getSelectedMountains() {
  return selectedMountains;
 }
 public void setSelectedMountains(String[] selectedMountains) {
  this.selectedMountains = selectedMountains;
 }

2、Action的设计:(x)q个更单了Q一句话Q由控制器切换到视图?PRE class=code>
 return mapping.findForward("success");
3、JSP的设计:(x)

  <html:form action="/multibox" name="multiboxForm" type="qiya.deng.struts.form.MultiboxForm">
   <logic:iterate name="multiboxForm" property="mountains" id="mountain">
    <html:multibox property="selectedMountains">
     <bean:write name="mountain"/>
    </html:multibox>
    <bean:write name="mountain"/><br/>
   </logic:iterate>
   <br/>
   <html:submit/><html:cancel/>
  </html:form>
q个相对比较复杂Q也是比较中要的?lt;logic:iterate/>是P代MultiboxForm中的mountians,
<html:multibox property="selectedMountains">
 <bean:write name="mountain"/>
</html:multibox>
q个标签的作用就是selecteDMountains的值和q代的mountaing致的时候就?x)选中?

接下来说RadioQ其实Form和Action部分都差不多Q只是JSP面有点不一PRadio里面甚至牉|CJavaScript?BR>1.From的设计:(x)


 private String selectedMountain = "Kangchenjunga West";
 private String[] mountains ={"Everest","K2","Kangchenjunga","Lhotse","Makalu","Kangchenjunga South","Lhotse Middle","Kangchenjunga West","Lhotse Shar","Cho Oyu"};
 
 public String[] getMountains() {
  return mountains;
 }
 public void setMountains(String[] mountains) {
  this.mountains = mountains;
 }
 public String getSelectedMountain() {
  return selectedMountain;
 }
 public void setSelectedMountain(String selectedMountain) {
  this.selectedMountain = selectedMountain;
 }
2.Action同上一P切换到JSP面厅R?nbsp;
3.重点部分JSP:

  <html:form action="/radio" name="radioForm" type="qiya.deng.struts.form.RadioForm">
   <bean:define id="selectedRadio" property="selectedMountain" name="radioForm"></bean:define>
   <logic:iterate id="mountain" property="mountains" name="radioForm">
    <bean:define id="mountainValue">
     <bean:write name="mountain"/>
    </bean:define>
    <html:radio property="selectedMountain" value="<%=mountainValue%>" styleId="<%=mountainValue%>"/>
    <bean:write name="mountain"/><br/>
   </logic:iterate><br/>
   <html:submit/><html:cancel/>
   <script type="text/javascript">
             <!--
          var selectedRadio =
             document.forms["radioForm"].elements["<bean:write name="selectedRadio"/>"];
              selectedRadio.checked=true;
             -->
         </script>
  </html:form>


"<bean:define/>"定义了一个PageContext作用域的属性selectedRadioQ下面的JavaScript的作用就是根据这个属性找到应该选中的Radio。其他的地方和上面那个很怼的。如果还是不太理解先q行Q看看生成的HTML代码?BR>



qiyadeng 2005-12-14 10:19 发表评论
]]>
tab tag 与Struts整合http://www.aygfsteel.com/qiyadeng/articles/22843.htmlqiyadengqiyadengWed, 07 Dec 2005 04:45:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/22843.htmlhttp://www.aygfsteel.com/qiyadeng/comments/22843.htmlhttp://www.aygfsteel.com/qiyadeng/articles/22843.html#Feedback2http://www.aygfsteel.com/qiyadeng/comments/commentRss/22843.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/22843.html发现一个比较酷的Tab标签Q这个标{־,但是基本上能适用于一般的应用。它的全U是The Ditchnet JSP Tabs Taglib Q)http://209.61.157.8:8080/taglibs/Q可以看出是JSP的标{。但是我们现在很多项目都是基于StrutsQ所以需要简单的来个整合?BR>
在它的网站上有比较详l的安装说明Qƈ且配有实例。需要的读者可以仔l查看,q里׃介绍了?BR>在用的JSP面中加?pre class="code">
<head>
   <tab:tabConfig/>
</head>
q是导入一些CSS和JavaScript.
然后基本上就是两套标{:(x)
<tab:tabContainer>
<tab:tabPane>
从命名我们就很容易看出来是什么作?lt;tab:tabContainer>是相当于容器一L(fng)东西可以包含很多?lt;tab:tabPane>,?lt;tab:tabPane>是我们要的那种Tab的效果的面板?pre class="code">
  <tab:tabContainer id="foo-bar-container">
     <tab:tabPane id="foo" tabTitle="姓名">
       <html:errors/><br/>
     <bean:message key="tab_textfield_name"/>
     <html:text property="userName"></html:text>
     <br/>
     <html:submit><bean:message key="tab_submit_label"/></html:submit>
   </tab:tabPane>
   <tab:tabPane id="bar" tabTitle="密码">
    <html:errors/><br/>
     <bean:message key="tab_textfield_password"/>
      <html:password property="password"/>
      <br/>
     <bean:message key="tab_textfield_repassword"/>
      <html:password property="rePassword"/>
      <br/>
     <html:submit><bean:message key="tab_submit_label"/></html:submit>
   </tab:tabPane>
  </tab:tabContainer>
注意上面的两个标{N有idq要是唯一的,而且是整个应用唯一?BR>
上面的代码就是一个表单,含有userName,password,rePassword三个文本域。但是需要一个Form,有没有考虑qForm攑֜什么位|呢Q经q试验我发现要将Form 攑ֈ<tab:tabContainer>的标{之外。这样就像处理一个普通的Struts Form一样了。如果你需要每个Tab也可以是个FormQ这样也没有什么问题?BR>
完整的JSP代码如下:


<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="tab" uri="<%@ taglib prefix="html" uri="<%@ taglib prefix="bean" uri="<html>
 <head>
  <tab:tabConfig/>
 </head>
  <body>
 <html:form action="/saveAll">
  <tab:tabContainer id="foo-bar-container">
    <tab:tabPane id="foo" tabTitle="姓名">
     <html:errors/><br/>
     <bean:message key="tab_textfield_name"/>
     <html:text property="userName"></html:text>
     <br/>
     <html:submit><bean:message key="tab_submit_label"/></html:submit>
   </tab:tabPane>
    <tab:tabPane id="bar" tabTitle="密码">
    <html:errors/><br/>
     <bean:message key="tab_textfield_password"/>
      <html:password property="password"/>
      <br/>
     <bean:message key="tab_textfield_repassword"/>
      <html:password property="rePassword"/>
      <br/>
     <html:submit><bean:message key="tab_submit_label"/></html:submit>
    </tab:tabPane>
   </tab:tabContainer>
 </html:form> 
 </body>
</html>
效果如图Q?BR>Snap2.bmp



qiyadeng 2005-12-07 12:45 发表评论
]]>
Struts之自定义Validatorhttp://www.aygfsteel.com/qiyadeng/articles/17571.htmlqiyadengqiyadengMon, 31 Oct 2005 10:00:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/17571.htmlhttp://www.aygfsteel.com/qiyadeng/comments/17571.htmlhttp://www.aygfsteel.com/qiyadeng/articles/17571.html#Feedback0http://www.aygfsteel.com/qiyadeng/comments/commentRss/17571.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/17571.html 比如我们惛_义一个规则来判定两次输入的密码是相等的。我们需要这样做Q首先我们需要一个类Q象q样?Q?br>
package com.motel168.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.validator.Field;
import org.apache.commons.validator.GenericValidator;
import org.apache.commons.validator.ValidatorAction;
import org.apache.commons.validator.ValidatorUtil;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.validator.Resources;

public class MyValidator {
    public static boolean validateTwoFields(Object bean,ValidatorAction va,Field field,ActionErrors errors,HttpServletRequest request){
       
        String value = ValidatorUtil.getValueAsString(bean,field.getProperty());
        String sProperty2 = field.getVarValue("secondProperty");
        String value2 = ValidatorUtil.getValueAsString(bean,sProperty2);
        if(!GenericValidator.isBlankOrNull(value)){
            try{
                if(!value.equals(value2)){
                    errors.add(field.getKey(),Resources.getActionError(request,va,field));
                    return false;
                }
            }catch(Exception e){
                errors.add(field.getKey(),Resources.getActionError(request,va,field));
                return false;
            }
        }
        return true;
    }
   
}

上面q个cd是用来判断两个域是否相等Q很单,但是注意Ҏ(gu)名一定要是validateXXX?br>
接下来需要扩展validator-rules.xml,?/global>之前加入q么一D?
      
             
   
 methodParams="java.lang.Object,org.apache.commons.validator.ValidatorAction,org.apache.commons.validator.Field,org.apache.struts.action.ActionErrors,javax.servlet.http.HttpServletRequest"
                   depends="required" msg="errors.twofield">
     
              function validateTwoFields(form){
              var bValid = true;
              var focusField = null;
              var i = 0;
              var fields = new Array();
              oTwoFields = new twofields();
              for(x in oTwoFields){
                  var field = form[oTwoFields[x][0]];
                  var secondField = form[oTwoFields[x][2]("secondProperty")];
                  if(field.type=="text"||field.type=="textarea"||field.type=="select-one"||field.type=="radio"||field.type=="password"){
                      var value;
                      var secondValue;
                      if(field.type=="select-one"){
                          var si = field.selectedIndex;
                          value = field.options[si].value;
                          secondValue = secondField.options[si].value;
                      }else{
                          value=field.value;
                          secondValue = secondField.value;
                      }
                      if(value!=secondValue){
                          if(i==0){
                              focusField = field;
                      }
                      fields[i++]=oTwoFields[x][1];
                      bValid = flase;
                  }
              }
          }
          if(fiels.length > 0){
              focusFiled.focus();
              alert(fields.join('\n'));
              }
          return bValid;
     
      ]]>
     

     
   
然后使用的时候就和其他没什么两L(fng)了:(x)
        

           
               
               
               
               
               
                    secondProperty
                    newPassword2
               

           

           
               
               
           

       



注意q个地方
                
                    secondProperty
                    newPassword2
               

是我们在javacMd的变量,它代表的是另外的一个域?br> 在JSP中的使用׃再说明了Q大功告?)?br>



qiyadeng 2005-10-31 18:00 发表评论
]]>
用AXIS开始WebService之设|?/title><link>http://www.aygfsteel.com/qiyadeng/articles/15215.html</link><dc:creator>qiyadeng</dc:creator><author>qiyadeng</author><pubDate>Tue, 11 Oct 2005 02:14:00 GMT</pubDate><guid>http://www.aygfsteel.com/qiyadeng/articles/15215.html</guid><wfw:comment>http://www.aygfsteel.com/qiyadeng/comments/15215.html</wfw:comment><comments>http://www.aygfsteel.com/qiyadeng/articles/15215.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qiyadeng/comments/commentRss/15215.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qiyadeng/services/trackbacks/15215.html</trackback:ping><description><![CDATA[<P>用AXIS开始WebService之设|?BR><A >http://ws.apache.org/axis/java/install.html</A><BR><A >http://www.chinaunix.net/jh/13/620370.html</A><BR>1.相关文g全部下蝲好:(x)<BR>主要文gQ?BR>axis-bin-1_2_1.zip 目前最新的<A >http://apache.justdn.org/ws/axis/1_2_1/</A><BR>依赖文gQ?BR>a.mail.jar 下蝲地址:http://java.sun.com/products/javamail <BR>b.activation.jar 下蝲地址:http://java.sun.com/products/javabeans/glasgow/jaf.html <BR>c.xerces.jar 下蝲地址:http://xml.apache.org/xerces-j/index.html 1.4.4版本<BR>d.xmlsec-1.2.1.jar 下蝲地址:http://xml.apache.org/security/</P> <P>2.相关讄<BR>a.把上面提到的a,b,c,d四个包拷贝到<CATALINA_HOME>/common/lib目录?BR>b.把axis目录下的WEB-INF/lib目录下的文g全部拯?lt;CATALINA_HOME>/common/lib目录?BR>c.把JAVA_HOME/lib/tools.jar拯?lt;CATALINA_HOME>/common/lib目录?/P> <P>q样应该OK?</P><img src ="http://www.aygfsteel.com/qiyadeng/aggbug/15215.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qiyadeng/" target="_blank">qiyadeng</a> 2005-10-11 10:14 <a href="http://www.aygfsteel.com/qiyadeng/articles/15215.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat中配|MySQLq接?/title><link>http://www.aygfsteel.com/qiyadeng/articles/15214.html</link><dc:creator>qiyadeng</dc:creator><author>qiyadeng</author><pubDate>Tue, 11 Oct 2005 02:13:00 GMT</pubDate><guid>http://www.aygfsteel.com/qiyadeng/articles/15214.html</guid><wfw:comment>http://www.aygfsteel.com/qiyadeng/comments/15214.html</wfw:comment><comments>http://www.aygfsteel.com/qiyadeng/articles/15214.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qiyadeng/comments/commentRss/15214.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qiyadeng/services/trackbacks/15214.html</trackback:ping><description><![CDATA[<P>1.把驱动拷贝到%TOMCAT_HOME%/common/lib目录?BR>2.新徏数据库表Qƈ向表中添加记?BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">use</SPAN><SPAN style="COLOR: #000000"> test;<BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">create</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">table</SPAN><SPAN style="COLOR: #000000"> testdata (<BR></SPAN><SPAN style="COLOR: #008080">3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>        id </SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">int</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #808080">not</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000"> auto_increment </SPAN><SPAN style="COLOR: #0000ff">primary</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">key</SPAN><SPAN style="COLOR: #000000">,<BR></SPAN><SPAN style="COLOR: #008080">4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>        foo </SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">varchar</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">25</SPAN><SPAN style="COLOR: #000000">), <BR></SPAN><SPAN style="COLOR: #008080">5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>        bar </SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">int</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">insert</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">into</SPAN><SPAN style="COLOR: #000000"> testdata </SPAN><SPAN style="COLOR: #0000ff">values</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">, </SPAN><SPAN style="COLOR: #ff0000">'</SPAN><SPAN style="COLOR: #ff0000">hello</SPAN><SPAN style="COLOR: #ff0000">'</SPAN><SPAN style="COLOR: #000000">, </SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">12345</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV> <P><BR>3.?TOMCAT_HOME%/config/server.xml文g中加入如下一D配|信??lt;/Host>之前)<BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">        </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000">数据库连接池配置</SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000">path:Your webApp directory</SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">Context </SPAN><SPAN style="COLOR: #ff0000">path</SPAN><SPAN style="COLOR: #0000ff">="/WS4Motel"</SPAN><SPAN style="COLOR: #ff0000"> docBase</SPAN><SPAN style="COLOR: #0000ff">="WS4Motel"</SPAN><SPAN style="COLOR: #ff0000"><BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #ff0000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>        debug</SPAN><SPAN style="COLOR: #0000ff">="5"</SPAN><SPAN style="COLOR: #ff0000"> reloadable</SPAN><SPAN style="COLOR: #0000ff">="true"</SPAN><SPAN style="COLOR: #ff0000"> crossContext</SPAN><SPAN style="COLOR: #0000ff">="true"</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000"> maxActive: Maximum number of dB connections in pool. Make sure you<BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         configure your mysqld max_connections large enough to handle<BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         all of your db connections. Set to 0 for no limit.<BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         </SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000"> maxIdle: Maximum number of idle dB connections to retain in pool.<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         Set to -1 for no limit.  See also the DBCP documentation on this<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         and the minEvictableIdleTimeMillis configuration parameter.<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         </SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000"> maxWait: Maximum time to wait for a dB connection to become available<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         in ms, in this example 10 seconds. An Exception is thrown if<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         this timeout is exceeded.  Set to -1 to wait indefinitely.<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         </SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000"> username and password: MySQL dB username and password for dB connections  </SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000"> driverClassName: Class name for the old mm.mysql JDBC driver is<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         org.gjt.mm.mysql.Driver - we recommend using Connector/J though.<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver.<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         </SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    <BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000"> url: The JDBC connection url for connecting to your MySQL dB.<BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         The autoReconnect=true argument to the url makes sure that the<BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         mm.mysql JDBC Driver will automatically reconnect if mysqld closed the<BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         connection.  mysqld by default closes idle connections after 8 hours.<BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>         </SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">Resource </SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="jdbc/WS4Motel"</SPAN><SPAN style="COLOR: #ff0000"> auth</SPAN><SPAN style="COLOR: #0000ff">="Container"</SPAN><SPAN style="COLOR: #ff0000"> type</SPAN><SPAN style="COLOR: #0000ff">="javax.sql.DataSource"</SPAN><SPAN style="COLOR: #ff0000"><BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #ff0000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>               maxActive</SPAN><SPAN style="COLOR: #0000ff">="100"</SPAN><SPAN style="COLOR: #ff0000"> maxIdle</SPAN><SPAN style="COLOR: #0000ff">="30"</SPAN><SPAN style="COLOR: #ff0000"> maxWait</SPAN><SPAN style="COLOR: #0000ff">="10000"</SPAN><SPAN style="COLOR: #ff0000"><BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #ff0000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>               username</SPAN><SPAN style="COLOR: #0000ff">="root"</SPAN><SPAN style="COLOR: #ff0000"> password</SPAN><SPAN style="COLOR: #0000ff">="83072674"</SPAN><SPAN style="COLOR: #ff0000"> driverClassName</SPAN><SPAN style="COLOR: #0000ff">="com.mysql.jdbc.Driver"</SPAN><SPAN style="COLOR: #ff0000"><BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #ff0000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>               url</SPAN><SPAN style="COLOR: #0000ff">="jdbc:mysql://localhost:3306/test?autoReconnect=true"</SPAN><SPAN style="COLOR: #0000ff">/></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">39</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff"></</SPAN><SPAN style="COLOR: #800000">Context</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">40</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>        </SPAN><SPAN style="COLOR: #008000"><!--</SPAN><SPAN style="COLOR: #008000">数据库连接池配置</SPAN><SPAN style="COLOR: #008000">--></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">41</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV> <P> </P> <P> 4.写个单程序测试下Q?BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ taglib uri</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">http://java.sun.com/jsp/jstl/sql</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> prefix</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">sql</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><%</SPAN><SPAN style="COLOR: #000000">@ taglib uri</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">http://java.sun.com/jsp/jstl/core</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> prefix</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">c</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">%></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">sql:query var</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">rs</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> dataSource</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">jdbc/TestDB</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>select id, foo, bar from testdata<BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"></</SPAN><SPAN style="COLOR: #000000">sql:query</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">html</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>  </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">head</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">title</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">DB Test</SPAN><SPAN style="COLOR: #000000"></</SPAN><SPAN style="COLOR: #000000">title</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>  </SPAN><SPAN style="COLOR: #000000"></</SPAN><SPAN style="COLOR: #000000">head</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>  </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">body</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>  </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">h2</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">Results</SPAN><SPAN style="COLOR: #000000"></</SPAN><SPAN style="COLOR: #000000">h2</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>  <BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">c:forEach var</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">row</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> items</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">${rs.rows}</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_361_369_Open_Image onclick="this.style.display='none'; Codehighlighter1_361_369_Open_Text.style.display='none'; Codehighlighter1_361_369_Closed_Image.style.display='inline'; Codehighlighter1_361_369_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_361_369_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_361_369_Closed_Text.style.display='none'; Codehighlighter1_361_369_Open_Image.style.display='inline'; Codehighlighter1_361_369_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top>    Foo $</SPAN><SPAN id=Codehighlighter1_361_369_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_361_369_Open_Text><SPAN style="COLOR: #000000">{row.foo}</SPAN></SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">br</SPAN><SPAN style="COLOR: #000000">/></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_385_393_Open_Image onclick="this.style.display='none'; Codehighlighter1_385_393_Open_Text.style.display='none'; Codehighlighter1_385_393_Closed_Image.style.display='inline'; Codehighlighter1_385_393_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_385_393_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_385_393_Closed_Text.style.display='none'; Codehighlighter1_385_393_Open_Image.style.display='inline'; Codehighlighter1_385_393_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top>    Bar $</SPAN><SPAN id=Codehighlighter1_385_393_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_385_393_Open_Text><SPAN style="COLOR: #000000">{row.bar}</SPAN></SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">br</SPAN><SPAN style="COLOR: #000000">/></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"></</SPAN><SPAN style="COLOR: #000000">c:forEach</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>  </SPAN><SPAN style="COLOR: #000000"></</SPAN><SPAN style="COLOR: #000000">body</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"></</SPAN><SPAN style="COLOR: #000000">html</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.aygfsteel.com/qiyadeng/aggbug/15214.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qiyadeng/" target="_blank">qiyadeng</a> 2005-10-11 10:13 <a href="http://www.aygfsteel.com/qiyadeng/articles/15214.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>获取本地L的MAC地址 http://www.aygfsteel.com/qiyadeng/articles/14625.htmlqiyadengqiyadengSat, 01 Oct 2005 15:24:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/14625.htmlhttp://www.aygfsteel.com/qiyadeng/comments/14625.htmlhttp://www.aygfsteel.com/qiyadeng/articles/14625.html#Feedback0http://www.aygfsteel.com/qiyadeng/comments/commentRss/14625.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/14625.html
 1/*
 2 FileName:MACHomework.java
 3 Author:浪子
 4 Date:2004-7-5
 5 E-mail:qiyadeng@hotmail.com
 6 Purpose:获取本地L的MAC地址
 7 */

 8import java.io.*;
 9import java.util.*;
10
11public class Main {
12    static private final int MACLength = 18;
13
14    public static void main(String args[]) {
15        System.out.print("本机的物理地址是:(x)");
16        System.out.println(getMACAddress());
17    }

18
19    static public String getMACAddress() {
20        SysCommand syscmd = new SysCommand();
21        //pȝ命o(h)
22        String cmd = "cmd.exe /c ipconfig/all";
23        Vector result;
24        result = syscmd.execute(cmd);
25        return getCmdStr(result.toString());
26    }

27
28    static public String getCmdStr(String outstr) {
29        String find = "Physical Address. . . . . . . . . :";
30        int findIndex = outstr.indexOf(find);
31        if (findIndex == -1{
32            return "未知错误Q?/SPAN>";
33        }
 else {
34            return outstr.substring(findIndex + find.length() + 1, findIndex
35                    + find.length() + MACLength);
36        }

37    }

38}

39
40//SysCommandc?/SPAN>
41class SysCommand {
42    Process p;
43
44    public Vector execute(String cmd) {
45        try {
46            Start(cmd);
47            Vector vResult = new Vector();
48            DataInputStream in = new DataInputStream(p.getInputStream());
49            BufferedReader myReader = new BufferedReader(new InputStreamReader(
50                    in));
51            String line;
52            do {
53                line = myReader.readLine();
54                if (line == null{
55                    break;
56                }
 else {
57                    vResult.addElement(line);
58                }

59            }
 while (true);
60            myReader.close();
61            return vResult;
62        }
 catch (Exception e) {
63            return null;
64
65        }

66
67    }

68
69    public void Start(String cmd) {
70        try {
71            if (p != null{
72                kill();
73            }

74            Runtime sys = Runtime.getRuntime();
75            p = sys.exec(cmd);
76
77        }
 catch (Exception e) {
78
79        }

80    }

81
82    public void kill() {
83        if (p != null{
84            p.destroy();
85            p = null;
86        }

87    }

88
89}

90


qiyadeng 2005-10-01 23:24 发表评论
]]>
JSP中文问题http://www.aygfsteel.com/qiyadeng/articles/14141.htmlqiyadengqiyadengMon, 26 Sep 2005 12:55:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/14141.htmlhttp://www.aygfsteel.com/qiyadeng/comments/14141.htmlhttp://www.aygfsteel.com/qiyadeng/articles/14141.html#Feedback2http://www.aygfsteel.com/qiyadeng/comments/commentRss/14141.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/14141.html一、JSP面昄q二、表单提交中文时出现q三、数据库q?
大家在JSP的开发过E中Q经常出C文ؕ码的问题Q可能一臛_扰着(zhn),我现在把我在JSP开发中遇到的中文ؕ码的问题?qing)解军_法写出来供大家参考?

一、JSP面昄q
下面的显C页?display.jsp)出Cؕ码:(x)

<html> 
<head>
<title>JSP的中文处?lt;/title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<%
out.print("JSP的中文处?quot;);
%>
</body>
</html>

对不同的WEB服务器和不同的JDK版本Q处理结果就不一栗原因:(x)服务器用的~码方式不同和浏览器对不同的字符昄l果不同而导致的。解军_法:(x)在JSP面中指定编码方?gb2312),卛_面的第一行加上:(x)<%@ page contentType="text/html; charset=gb2312"%>Q就可以消除q了。完整页面如下:(x)
<%@ page contentType="text/html; charset=gb2312"%> 
<html>
<head>
<title>JSP的中文处?lt;/title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<%
out.print("JSP的中文处?quot;);
%>
</body>
</html>

二、表单提交中文时出现q
下面是一个提交页?submit.jsp)Q代码如下:(x)

<html> 
<head>
<title>JSP的中文处?lt;/title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<form name="form1" method="post" action="process.jsp">
<div align="center">
<input type="text" name="name">
<input type="submit" name="Submit" value="Submit">
</div>
</form>
</body>
</html>

下面是处理页?process.jsp)代码Q?
<%@ page contentType="text/html; charset=gb2312"%> 
<html>
<head>
<title>JSP的中文处?lt;/title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<%=request.getParameter("name")%>
</body>
</html>

如果submit.jsp提交英文字符能正显C,如果提交中文时就?x)出Cؕ码。原因:(x)览器默认用UTF-8~码方式来发送请求,而UTF-8和GB2312~码方式表示字符时不一Pq样出C不能识别字符。解军_?通过request.setCharacterEncoding("gb2312")对请求进行统一~码Q就实现了中文的正常昄。修改后的process.jsp代码如下Q?pre class="code"><%@ page contentType="text/html; charset=gb2312"%>
<%
request.seCharacterEncoding("gb2312");
%>
<html>
<head>
<title>JSP的中文处?lt;/title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<%=request.getParameter("name")%>
</body>
</html>

三、数据库q接出现q
只要涉及(qing)中文的地方全部是qQ解军_法:(x)在数据库的数据库URL中加上useUnicode=true&characterEncoding=GBKO(jin)K了?

四、数据库的显CZؕ?
在mysql4.1.0?varcharcdQtextcd׃(x)出现中文qQ对于varcharcd把它设ؓ(f)binary属性就可以解决中文问题Q对于textcdp用一个编码{换类来处理,实现如下Q?

public class Convert { 
/** 把ISO-8859-1码{换成GB2312
*/
public static String ISOtoGB(String iso){
String gb;
try{
if(iso.equals("") || iso == null){
return "";
}
else{
iso = iso.trim();
gb = new String(iso.getBytes("ISO-8859-1"),"GB2312");
return gb;
}
}
catch(Exception e){
System.err.print("~码转换错误Q?quot;+e.getMessage());
return "";
}
}
}
把它~译成classQ就可以调用Convertcȝ静态方法ISOtoGB()来{换编码?



qiyadeng 2005-09-26 20:55 发表评论
]]>
研究了下 Struts-Layouthttp://www.aygfsteel.com/qiyadeng/articles/14131.htmlqiyadengqiyadengMon, 26 Sep 2005 09:42:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/14131.htmlhttp://www.aygfsteel.com/qiyadeng/comments/14131.htmlhttp://www.aygfsteel.com/qiyadeng/articles/14131.html#Feedback1http://www.aygfsteel.com/qiyadeng/comments/commentRss/14131.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/14131.htmlhttp://struts.application-servers.com/index.html
一.配置Q?BR>http://struts.application-servers.com/install.html有详l的说明
1.把下面的两端加入到struts-config.xml中:(x)
<action path="/sort"
 type
="fr.improve.struts.taglib.layout.sort.SortAction"
 scope
="request"
 validate
="false">
action>
    
<action path="/treeview"
 type
="fr.improve.struts.taglib.layout.treeview.TreeviewAction"
 scope
="request"
 validate
="false">
action>

2.复制struts-layout.jar到WEB-INF/lib目录?BR>3.在web.xml文g中加入:(x)
   <jsp-config>
    
<taglib>
     
<taglib-uri>http://struts.application-servers.com/layouttaglib-uri>
     
<taglib-location>/WEB-INF/struts-layout.tldtaglib-location>
    
taglib>
   
jsp-config>

4.把struts-layout.tld复制到WEB-INF目录?BR>5.把resources文g下的config文g拯到webroot目录下,q把images目录下的所有文件拷贝到config目录下?BR>?实例q行Q?BR>写个一般的jspQ当然对应的Action,ActionForm已经写好了?BR>
<%@ taglib uri="http://struts.application-servers.com/layout" prefix="layout"%>
<layout:html>
 
<layout:form action="/layout" styleClass="FORM">
  
<layout:text key="search.name" property="name" styleClass="FIELD"/>
  
<layout:text key="search.town" property="town" styleClass="FIELD"/>
  
<layout:date key="serach.date" property="date" styleClass="LABEL"/>
  
<layout:submit>
   
<layout:message key="search.submit"/>
  
layout:submit>
 
layout:form>
layout:html>
Snap1.bmp

qiyadeng 2005-09-26 17:42 发表评论
]]>
iReport的简单配|?/title><link>http://www.aygfsteel.com/qiyadeng/articles/13951.html</link><dc:creator>qiyadeng</dc:creator><author>qiyadeng</author><pubDate>Sat, 24 Sep 2005 13:26:00 GMT</pubDate><guid>http://www.aygfsteel.com/qiyadeng/articles/13951.html</guid><wfw:comment>http://www.aygfsteel.com/qiyadeng/comments/13951.html</wfw:comment><comments>http://www.aygfsteel.com/qiyadeng/articles/13951.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qiyadeng/comments/commentRss/13951.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qiyadeng/services/trackbacks/13951.html</trackback:ping><description><![CDATA[<P>iReport是个好东西,现在已经出来?.5.1的版本了Q但是这个工兯然好用,但是初用还是会(x)遇到不小的麻烦?BR>下面说下iReport的基本配|:(x)<BR>1.一般用iReport的同志都是用Java的,所有配|JDK的环境就不说了^_^?/P> <P>2.当然需要去下蝲iReport-0.5.1了,记得q的捎上个iTextAsian.jarQ这是我们中国h需要的东西?BR>解压iReport-0.5.1Q把\lib目录下的tinylaf.jar,mysql-connector-java-3.0.8-stable-bin.jarq两个文件删除,然后把iTextAsian.jar拯到\lib目录下(tinylaf.jar文g和iTextAsian.jar有冲H,tinylaf.jar文g删了不会(x)影响使用Q只是会(x)影响一点美观,应该不关pM大^_^Q,其他的配|都不需要了Q双击该目录下的iReport.batq行iReport?/P> <P>3.新徏一个文档看看,q往其中d一个Static TextQ写上中文,q择如下QFont name:宋体QPDF font nameQSTSong-Light,PDF Encoding:UniGB-UCS2-H(Chinese Simplified)q三必修修改,要不中文?x)有问题?BR><IMG height=380 alt=iReport1.jpg src="http://www.aygfsteel.com/images/blogjava_net/qiyadeng/j2ee/iReport/iReport1.jpg" width=370 border=0></P> <P>4.讄 DataSource--Connections/DataSourceq新建,mysql讄如下,q要把你的驱动拷贝到\lib目录下,记得上面删了个mysql-connector-java-3.0.8-stable-bin.jar东西吗?q个东西不知道ؓ(f)什么也不能用,q是用mysql-connector-java-3.1.10-bin.jar?BR><IMG height=415 alt=iReport2.jpg src="http://www.aygfsteel.com/images/blogjava_net/qiyadeng/j2ee/iReport/iReport2.jpg" width=403 border=0></P> <P>5.重新启动iReportQ再打开Connections/DataSource试下,应该?x)提CZ成功的。然后选择菜单builder-set active connection.q样可以用了SQL语句了。选择菜单View-Report query,写上句简单的SQL语句Q下面就?x)显C出字段?BR><IMG height=500 alt=iReport3.jpg src="http://www.aygfsteel.com/images/blogjava_net/qiyadeng/j2ee/iReport/iReport3.jpg" width=520 border=0></P> <P>6.选择view-Report-fieldQ然后再d个Field到报表中按提C操作,提醒下,注意下字D늚cdQ不正确的话?x)出错。如果含有中问的话,处理同上3?/P> <P>q行下看下效?builder-Execute Report(using active conn))Q?/P> <P><IMG style="WIDTH: 685px; HEIGHT: 556px" height=733 alt=iReport4.jpg src="http://www.aygfsteel.com/images/blogjava_net/qiyadeng/j2ee/iReport/iReport4.jpg" width=1000 border=0></P><img src ="http://www.aygfsteel.com/qiyadeng/aggbug/13951.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qiyadeng/" target="_blank">qiyadeng</a> 2005-09-24 21:26 <a href="http://www.aygfsteel.com/qiyadeng/articles/13951.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在web project中用log4jhttp://www.aygfsteel.com/qiyadeng/articles/13834.htmlqiyadengqiyadengFri, 23 Sep 2005 06:16:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/13834.htmlhttp://www.aygfsteel.com/qiyadeng/comments/13834.htmlhttp://www.aygfsteel.com/qiyadeng/articles/13834.html#Feedback0http://www.aygfsteel.com/qiyadeng/comments/commentRss/13834.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/13834.html在web project中用log4j

下面我们以在tomcat中示范怎么配置和用log4j

环境讄Q用qtomcat的都知道Q应该把log4j.jar文g拯?TOMCAT_HOME%\common\lib中?BR>~辑servlet:

 1package my.scwcd;
 2
 3
 4import javax.servlet.ServletException;
 5import javax.servlet.http.HttpServlet;
 6
 7import org.apache.log4j.PropertyConfigurator;
 8
 9public class Log4jInit extends HttpServlet {
10
11 public Log4jInit() {
12  super();
13 }

14
15 public void destroy() {
16  super.destroy(); // Just puts "destroy" string in log
17 }

18
19 public void init() throws ServletException {
20  String path = getServletContext().getRealPath("/");
21  
22  String file = getInitParameter("log4j");
23  if(file != null){
24   PropertyConfigurator.configure(path+file);
25  }

26  
27 }

28
29}

30
31


q在web.xml中加入如下配|:(x)

 1  <servlet>
 2    <servlet-name>Log4jInit</servlet-name>
 3    <servlet-class>my.scwcd.Log4jInit</servlet-class>
 4    <init-param>
 5     <param-name>log4j</param-name>
 6     <param-value>WEB-INF\log4j.properties</param-value>
 7    </init-param>
 8    <load-on-startup>1</load-on-startup>
 9  </servlet>
10


注意上面<param-value>中的"\"在linux要写?/"?BR>q有加上log4j.properties文g在WEB-INF目录?BR>

log4j.rootLogger=INFO, A1 , R
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=log4j.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

 

下面写了两个试的程序:(x)
servlet Test.java中:(x)

 1 public void doGet(HttpServletRequest request, HttpServletResponse response)
 2   throws ServletException, IOException {
 3
 4  response.setContentType("text/html");
 5  PrintWriter out = response.getWriter();
 6  Logger logger = Logger.getLogger(Test.class);
 7  logger.info("Test use Logging for Servlet");
 8  out.println("<h1>Success<h1>");
 9  out.flush();
10  out.close();
11 }

12
13


JSP temp.jsp中:(x)

1   <%
2    response.setContentType("text/html");
3  Logger logger = Logger.getLogger("temp.jsp");
4  logger.info("Test use Logging for JSP");
5  out.println("<h1>Success<h1>");
6   %>
7


q样?TOMCAT_HOME%\bin目录下会(x)产生log4j.log的文Ӟq就是日志文件?/P>

qiyadeng 2005-09-23 14:16 发表评论
]]>
在应用程序中使用log4jhttp://www.aygfsteel.com/qiyadeng/articles/13819.htmlqiyadengqiyadengFri, 23 Sep 2005 03:15:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/13819.htmlhttp://www.aygfsteel.com/qiyadeng/comments/13819.htmlhttp://www.aygfsteel.com/qiyadeng/articles/13819.html#Feedback0http://www.aygfsteel.com/qiyadeng/comments/commentRss/13819.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/13819.html1、在应用E序中用log4j
2、把log4j-*.*jar攑օCLASSPATH变量?BR>~辑如下单java文gQ?BR>

 1package logging;
 2import org.apache.log4j.Logger;
 3import org.apache.log4j.PropertyConfigurator;
 4
 5public class TestLog4j {
 6
 7 static Logger logger = Logger.getLogger(TestLog4j.class);
 8 
 9 public static void main(String args[]){
10  PropertyConfigurator.configure("log4j.properties");
11  logger.info("Hello World");
12  logger.error("Hello World");
13  logger.warn("Hello World");
14  logger.debug("Hello World");
15 }

16}

17
18


新徏一个配|文件log4j.propertiesQ?PRE class=code>
log4j.rootLogger=WARN, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
#log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
# Print the date in ISO 8601 format
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
# Print only messages of level WARN or above in the package com.foo.
log4j.logger.com.foo=WARN

~译q运行TestLog4j?x)在目录下生成一个example.log的文Ӟ屏幕也会(x)输出信息Q这证明已经你已l成功了W一步?BR>下面解释下这些配|文?BR>
log4j.rootLogger = [ level ], appendName1, appendName2, …appendNameN。同一个记录器可有多个输出端?BR>PSQlevel的别(此别可以自定义Q系l默认提供了以下U别Q?BR>debug//调试信息
info//一般信?BR>warn//警告信息
error//错误信息
fatal//致命错误信息
上面列出的就是所谓log4j的输出别,log4j只?个别,它们从上C分别为ERROR、WARN、INFO、DEBUGQ假设你定义的别是infoQ那么error和warn的日志可以显C比他低的debug信息׃昄了?
log4j.appender.appenderName = fully.qualified.name.of.appender.class。log4j提供了以下几U常用的输出目的圎ͼ(x)
org.apache.log4j.ConsoleAppenderQ将日志信息输出到控制台
org.apache.log4j.FileAppenderQ将日志信息输出C个文?BR>org.apache.log4j.DailyRollingFileAppenderQ将日志信息输出C个,q且每天输出C个新的日志文?BR>org.apache.log4j.RollingFileAppenderQ将日志信息输出C个文Ӟ通过指定文g的的寸Q当文g大小到达指定寸的时候会(x)自动把文件改名,如名为example.log的文件会(x)改名?example.log.1Q同时生一个新的example.log文g。如果新的文件再ơ达到指定尺寸,又会(x)自动把文件改名ؓ(f) example.log.2Q同时生一个example.log文g。依此类推,直到example.log. MaxBackupIndexQ?MaxBackupIndex的值可在配|文件中定义?BR>org.apache.log4j.WriterAppenderQ将日志信息以流格式发送到L指定的地斏V?BR>org.apache.log4j.jdbc.JDBCAppenderQ通过JDBC把日志信息输出到数据库中?BR>
Log4j提供了一下几U布局Q?BR>org.apache.log4j.HTMLLayoutQ以HTML表格形式布局
org.apache.log4j.PatternLayoutQ可以灵zd指定布局模式
org.apache.log4j.SimpleLayoutQ包含日志信息的U别和信息字W串

定义一个PatternLayout布局的语句ؓ(f)Q?BR>log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1} - %m%n
PSQConversionPattern参数的格式含?BR>格式?含义
%c 输出日志信息所属的cȝ全名
%d 输出日志旉点的日期或时_(d)默认格式为ISO8601Q也可以在其后指定格式,比如Q?d{yyy-MM-dd HH:mm:ss }Q输出类|(x)2002-10-18- 22Q?0Q?8
%f 输出日志信息所属的cȝcd
%l 输出日志事g的发生位|,卌出日志信息的语句处于它所在的cȝW几?BR>%m 输出代码中指定的信息Q如log(message)中的message
%n 输出一个回车换行符QW(xu)indowsq_为“\r\n”,Unixq_为“\n?BR>%p 输出优先U,即DEBUGQINFOQW(xu)ARNQERRORQFATAL。如果是调用debug()输出的,则ؓ(f)DEBUGQ依此类?BR>%r 输出自应用启动到输出该日志信息所耗费的毫U数
%t 输出产生该日志事件的U程?BR>
另外很好的学?fn)笔讎ͼ?x)
http://www.sentom.net/list.asp?id=59
http://www.sentom.net/list.asp?id=60
http://www.sentom.net/list.asp?id=61



qiyadeng 2005-09-23 11:15 发表评论
]]>
用java写个MD5加密的类http://www.aygfsteel.com/qiyadeng/articles/13578.htmlqiyadengqiyadengTue, 20 Sep 2005 13:24:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/13578.htmlhttp://www.aygfsteel.com/qiyadeng/comments/13578.htmlhttp://www.aygfsteel.com/qiyadeng/articles/13578.html#Feedback0http://www.aygfsteel.com/qiyadeng/comments/commentRss/13578.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/13578.html

׃一个应用,我需要一个MD5法加密数据Q我查看了网上一些资料,发现其他的语a都是要自己实现的Q但是Java很单,因ؓ(f)java中的cdl处理好了,而且q可以选其他的加密法Q如SHAQ下面就l一个例?/p>

/*
 * Created on 2005-5-21
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.merrylin.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class MD5Class {

 public static String MD5Encrypt(String inStr) {
  MessageDigest md = null;
  String outStr = null;

  try {
   md = MessageDigest.getInstance("MD5");       //可以选中其他的算法如SHA
   byte[] digest = md.digest(inStr.getBytes());       //q回的是byet[]Q要转化为String存储比较方便
   outStr = bytetoString(digest);
  } catch (NoSuchAlgorithmException nsae) {
   nsae.printStackTrace();
  }

  return outStr;
 }

 public static String bytetoString(byte[] digest) {
  String str = "";
  String tempStr = "";

  for (int i = 1; i < digest.length; i++) {
   tempStr = (Integer.toHexString(digest[i] & 0xff));
   if (tempStr.length() == 1) {
    str = str + "0" + tempStr;
   } else {
    str = str + tempStr;
   }
  }

  return str.toLowerCase();
 }

}

单吧Q如果你只是要应用,可以不知道MD5的算法了Q但是要想知道更多,可以参看|上的源码或?a >http://www.donews.net/qiyadeng/archive/2005/05/26/399340.aspx。但是注意MD5加密法Q破解还是很困难Q虽然报道称׃大学的王云教授好像是已l寻扑ֈ了破解的Ҏ(gu)?/font>



qiyadeng 2005-09-20 21:24 发表评论
]]>
JBoss配置Mysqlq接?/title><link>http://www.aygfsteel.com/qiyadeng/articles/13577.html</link><dc:creator>qiyadeng</dc:creator><author>qiyadeng</author><pubDate>Tue, 20 Sep 2005 13:23:00 GMT</pubDate><guid>http://www.aygfsteel.com/qiyadeng/articles/13577.html</guid><wfw:comment>http://www.aygfsteel.com/qiyadeng/comments/13577.html</wfw:comment><comments>http://www.aygfsteel.com/qiyadeng/articles/13577.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qiyadeng/comments/commentRss/13577.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qiyadeng/services/trackbacks/13577.html</trackback:ping><description><![CDATA[<div>对于jsp的webE序来说Q配|连接池是必不可的。JBoss配置MySql的连接池Q可以查看官Ҏ(gu)档,地址为:(x)<a >http://docs.jboss.org/jbossas/getting_started/v4/html/db.html</a>?/div><div>我这里的配置分ؓ(f)以下几步Q?/div><div>W一步:(x)从jboss-4.0.2\docs\examples\jca目录下的mysql-ds.xml复制文g到D:\jboss-4.0.2\server\default\deploy目录下ƈ~辑如下Q?/div><pre class="code"><div><?xml version="1.0" encoding="UTF-8"?></div><div><!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ --><br/><!--  Datasource config for MySQL using 3.0.9 available from:<br/><a >http://www.mysql.com/downloads/api-jdbc-stable.html</a><br/>--></div><div><datasources><br/>  <local-tx-datasource><br/>    <jndi-name>MySqlDS</jndi-name><br/>    <connection-url>jdbc:mysql://localhost:3306/test</connection-url><br/>    <driver-class>com.mysql.jdbc.Driver</driver-class><br/>    <user-name>root</user-name><br/>    <password>root</password><br/>    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name><br/>    <!-- sql to call when connection is created<br/>    <new-connection-sql>some arbitrary sql</new-connection-sql><br/>      --><br/>    <!-- sql to call on an existing pooled connection when it is obtained from pool <br/>    <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql><br/>      --></div><div>    <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --><br/>    <metadata><br/>       <type-mapping>mySQL</type-mapping><br/>    </metadata><br/>  </local-tx-datasource><br/></datasources></div></pre><div>W二步:(x)~辑jboss-4.0.2\server\default\conf下的三个文gQstandardjbosscmp-jdbc.xmlQstandardjaws.xmlQlogin-config.xml</div><div>standardjbosscmp-jdbc.xml修改部分Q?/div><pre class="code"><div>      <datasource>java:/MySqltDS</datasource><br/>      <datasource-mapping>mySQL</datasource-mapping></div></pre><div>standardjaws.xml修改部分Q?/div><pre class="code"><div>   <datasource>java:/MySqltDS</datasource><br/>   <type-mapping>mySQL</type-mapping></div></pre><div>login-config.xml修改部分Q(可以dq一D,复制一D进行修改)</div><pre class="code"><div>    <application-policy name = "MySqlDbRealm"><br/>       <authentication><br/>          <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"<br/>             flag = "required"><br/>             <module-option name = "principal">test</module-option><br/>             <module-option name = "userName">root</module-option><br/>             <module-option name = "password">root</module-option><br/>             <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option><br/>          </login-module><br/>       </authentication><br/>    </application-policy></div></pre><div></div><div>W三步:(x)重启jboss没有出现异常Q就?x)有如下昄Q证明配|正:(x)</div><div><IMG height=20 alt=pool.jpg src="http://www.aygfsteel.com/images/blogjava_net/qiyadeng/j2ee/pool.jpg" width=777 border=0></div><div>W四步:(x)如果你还步放心,现在写个servlet试试吧:(x)</div><pre class="code"><div>  response.setContentType("text/html;charset=gb2312");<br/>  PrintWriter out = response.getWriter();<br/>  try {<br/>   // Put your code here<br/>   Context cx  = new InitialContext();<br/>   Object obj = cx.lookup("java:/MySqlDS");<br/>   DataSource ds = (DataSource)obj;<br/>   Connection connect = ds.getConnection();<br/>   Statement stmt = connect.createStatement();<br/>   ResultSet rs = stmt.executeQuery("select * from customers");<br/>   while(rs.next()){<br/>    out.println(rs.getString("name"));<br/>   }<br/>  } catch (NamingException e) {<br/>   e.printStackTrace();<br/>  } catch(SQLException e1){<br/>   e1.printStackTrace();<br/>  }<br/>  out.flush();<br/>  out.close();</div></pre><img src ="http://www.aygfsteel.com/qiyadeng/aggbug/13577.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qiyadeng/" target="_blank">qiyadeng</a> 2005-09-20 21:23 <a href="http://www.aygfsteel.com/qiyadeng/articles/13577.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>native2ascii--java国际化工?/title><link>http://www.aygfsteel.com/qiyadeng/articles/13576.html</link><dc:creator>qiyadeng</dc:creator><author>qiyadeng</author><pubDate>Tue, 20 Sep 2005 13:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/qiyadeng/articles/13576.html</guid><wfw:comment>http://www.aygfsteel.com/qiyadeng/comments/13576.html</wfw:comment><comments>http://www.aygfsteel.com/qiyadeng/articles/13576.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qiyadeng/comments/commentRss/13576.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qiyadeng/services/trackbacks/13576.html</trackback:ping><description><![CDATA[<BR>native2ascii虽然是个很小的工?但是用处不小.在我们这些非p国家特别有用,如一些Strut和JSF的配|文?如果要用中文就必须要用到该工具.<BR>如下面这?使用h很方?<BR><PRE class=code>[root@localhost root]# native2ascii<BR>你好世界!<BR>\u4f60\u597d\u4e16\u754c!<BR></PRE><BR>但是我好像发现点问题,我用eclipse(MyEclipse)~辑完的文g,用中文写?没有办法来转换,不知道什么原?<BR>当然native2asciiq不臌些用?是在反~译别h的程序中,也可以把那些Unicode转化成中?<BR><img src ="http://www.aygfsteel.com/qiyadeng/aggbug/13576.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qiyadeng/" target="_blank">qiyadeng</a> 2005-09-20 21:21 <a href="http://www.aygfsteel.com/qiyadeng/articles/13576.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Servlet和JSP中访问web.xml讄的初始参?/title><link>http://www.aygfsteel.com/qiyadeng/articles/13575.html</link><dc:creator>qiyadeng</dc:creator><author>qiyadeng</author><pubDate>Tue, 20 Sep 2005 13:20:00 GMT</pubDate><guid>http://www.aygfsteel.com/qiyadeng/articles/13575.html</guid><wfw:comment>http://www.aygfsteel.com/qiyadeng/comments/13575.html</wfw:comment><comments>http://www.aygfsteel.com/qiyadeng/articles/13575.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qiyadeng/comments/commentRss/13575.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qiyadeng/services/trackbacks/13575.html</trackback:ping><description><![CDATA[<p>在JSP和Servlet中有时候需要读取web.xml的初始化参数Q比如可以用于设|JNDI的数据源的名字。下面简单介l下在JSP和Servlet中怎么dweb.xml的初始化参数?/p><p>一、在Servlet中读取:(x)</p><p>在Servlet中一般可以用ServletConfig对象的getInitParameterҎ(gu)去读取指定的参数的倹{D个例子:(x)</p><p>新徏一个ServletQReadInitParameter.java</p><p>q在web.xml中增加如下配|:(x)</p><p></p><pre class="code">  <servlet><br/>    <servlet-name>ReadInitParameter</servlet-name><br/>    <servlet-class>com.test.ReadInitParameter</servlet-class><br/>    <init-param><br/>      <param-name>email</param-name><br/>      <param-value>qiyadeng@haha.com</param-value><br/>    </init-param><br/>    <init-param><br/>      <param-name>name</param-name><br/>      <param-value>qiyadeng</param-value><br/>    </init-param><br/>  </servlet></pre><br/>   <servletclass>com.test.ReadInitParameter</servlet-class>是servlet的完整\径,包括包名?p></p><p>配置好了web.xmlQ现在可以在E序中读取初始化的参C。在init(ServletConfig config)Ҏ(gu)中传递了一个ServletConfig参数Q可以这栯取初始化参数Q?/p><p></p><pre class="code">  public void init(ServletConfig config) throws ServletException<br/>  {<br/>    super.init(config);<br/>    String email = config.getInitParameter("email");<br/>    String name = config.getInitParameter("name");<br/>  }</pre><br/>在其他的Ҏ(gu)中象doGet(),doPost(),service()Ҏ(gu)中可以用getServeltConfig()Ҏ(gu)得到一个ServetConfig对象Q在利用该对象的getInitParameter()Ҏ(gu)取到对应的初始化参数?p></p><p></p><pre class="code"><strong>  </strong>String email   = getServletConfig().getInitParameter<strong>("</strong>email<b>");<br/>  </b>String name= getServletConfig().getInitParameter<strong>("</strong>name<strong>");</strong></pre><p></p><p>二、在JSP中读取:(x)</p><p>在JSP中读取的方式和Servlet中的doGet(),doPost(),Service()的方法一P都是由ServletConfig对象来读取的?/p><p></p><pre class="code">  <%<br/>    String zhutou = getServletConfig().getInitParameter("zhutou");<br/>    String zhutouname = getServletConfig().getInitParameter("zhutouname");</pre><br/>  %><p></p><p>但是Q在web.xml的配|需要注意一?新增如下Q?/p><p></p><pre class="code">  <servlet><br/>    <servlet-name>ReadInitParam</servlet-name><br/>    <jsp-file>ReadInitParam.jsp</jsp-file><br/>    <init-param><br/>      <param-name>zhutou</param-name><br/>      <param-value>zhutou@hotmail.com</param-value><br/>    </init-param><br/>    <init-param><br/>      <param-name>zhutouname</param-name><br/>      <param-value>zhutou</param-value><br/>    </init-param><br/>  </servlet></pre><p></p><p>在servlet-mapping中也要配|好Q?/p><p></p><pre class="code">  <servlet-mapping><br/>    <servlet-name>ReadInitParam</servlet-name><br/>    <url-pattern>ReadInitParam.jsp</url-pattern><br/>  </servlet-mapping></pre><p></p><p>上面的ReadInitParam.jsp出现的标{N要jsp文g的全部\径?/p><img src ="http://www.aygfsteel.com/qiyadeng/aggbug/13575.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qiyadeng/" target="_blank">qiyadeng</a> 2005-09-20 21:20 <a href="http://www.aygfsteel.com/qiyadeng/articles/13575.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>web-app_2_2.xml(仅供学习(fn)方便) http://www.aygfsteel.com/qiyadeng/articles/13570.htmlqiyadengqiyadengTue, 20 Sep 2005 12:59:00 GMThttp://www.aygfsteel.com/qiyadeng/articles/13570.htmlhttp://www.aygfsteel.com/qiyadeng/comments/13570.htmlhttp://www.aygfsteel.com/qiyadeng/articles/13570.html#Feedback0http://www.aygfsteel.com/qiyadeng/comments/commentRss/13570.htmlhttp://www.aygfsteel.com/qiyadeng/services/trackbacks/13570.html阅读全文

qiyadeng 2005-09-20 20:59 发表评论
]]>
Struts国际化步?/title><link>http://www.aygfsteel.com/qiyadeng/articles/13569.html</link><dc:creator>qiyadeng</dc:creator><author>qiyadeng</author><pubDate>Tue, 20 Sep 2005 12:56:00 GMT</pubDate><guid>http://www.aygfsteel.com/qiyadeng/articles/13569.html</guid><wfw:comment>http://www.aygfsteel.com/qiyadeng/comments/13569.html</wfw:comment><comments>http://www.aygfsteel.com/qiyadeng/articles/13569.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qiyadeng/comments/commentRss/13569.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qiyadeng/services/trackbacks/13569.html</trackback:ping><description><![CDATA[<p>对Struts实行国际?br/>(1)讄字符~码<br/>Z保证在同一JSP面能支持多U语aQ可以将所有JSP面的字W编码统一讄?quot;UTF-8"<br/></p><pre class="code"><%@ page contentType="text/html;charset=UTF-8" language="java"%></pre><br/>(2)Ҏ(gu)本,按钮Q图片国际化<br/>(3)创徏英文Q中文资源文?br/>(4)对中文资源文件进行编码{?br/>用JDK中的native2ascii工具对中文资源进行{?br/><pre class="code">native2ascii -encoding gb2312 applicaion_CN.properties application_CN.properties</pre><br/>(5)采用Servletqo(h)器设|请求数据的字符~码<br/>d如下cSetCharacterEncodingFilter:<br/><pre class="code">package com.yourcompany.struts;<p></p><p>import java.io.IOException;</p><p>import javax.servlet.Filter;<br/>import javax.servlet.FilterChain;<br/>import javax.servlet.FilterConfig;<br/>import javax.servlet.ServletException;<br/>import javax.servlet.ServletRequest;<br/>import javax.servlet.ServletResponse;</p><p>public class SetCharacterEncodingFilter implements Filter {</p><p> public void init(FilterConfig arg0) throws ServletException {<br/> }</p><p> public void doFilter(ServletRequest request, ServletResponse response,<br/>   FilterChain chain) throws IOException, ServletException {<br/>  request.setCharacterEncoding("UTF-8");<br/>  chain.doFilter(request,response);</p><p> }</p><p> public void destroy() {<br/> }</p><p>}</p></pre><br/>q在web.xml中添加如下设|:(x)<br/>  <pre class="code"> <filter><br/>    <filter-name>Character Encoding</filter-name><br/>    <filter-class>com.yourcompany.struts.SetCharacterEncodingFilter</filter-class><br/>   </filter><br/>   <filter-mapping><br/>    <filter-name>Character Encoding</filter-name><br/>    <url-pattern>/*</url-pattern><br/>   </filter-mapping></pre><p></p><p><br/></p><img src ="http://www.aygfsteel.com/qiyadeng/aggbug/13569.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qiyadeng/" target="_blank">qiyadeng</a> 2005-09-20 20:56 <a href="http://www.aygfsteel.com/qiyadeng/articles/13569.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ֳ</a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˫</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">«ɽ</a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ֵ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">̰</a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ʯ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̫</a>| <a href="http://" target="_blank">ޭ</a>| <a href="http://" target="_blank">ν</a>| <a href="http://" target="_blank">ʲ</a>| <a href="http://" target="_blank">ԭ</a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">Ȩ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ļ</a>| <a href="http://" target="_blank">ɾ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>