??xml version="1.0" encoding="utf-8" standalone="yes"?>久久精品国产一区二区三区,日韩欧美精品在线视频,欧美日韩精品一区二区在线播放 http://www.aygfsteel.com/jsong/jsongBlogzh-cnSat, 05 Jul 2025 07:41:29 GMTSat, 05 Jul 2025 07:41:29 GMT60ibateshttp://www.aygfsteel.com/jsong/archive/2008/07/17/215534.htmlJsongJsongThu, 17 Jul 2008 08:36:00 GMThttp://www.aygfsteel.com/jsong/archive/2008/07/17/215534.htmlhttp://www.aygfsteel.com/jsong/comments/215534.htmlhttp://www.aygfsteel.com/jsong/archive/2008/07/17/215534.html#Feedback0http://www.aygfsteel.com/jsong/comments/commentRss/215534.htmlhttp://www.aygfsteel.com/jsong/services/trackbacks/215534.html 需要下?个ibates的jar?分别是ibatis-2.3.0.677.jar, ibatis-common-2.jar, ibatis-sqlmap.jar  把这个包复制到项目下的LIB下面
写一个POJO 实体bean 实现序列化接?br /> public class Tmac implements Serializable {

  public Integer id;
 
  public String name;

 public String getName() {
  return name;
 }

 public void setName(String name) {
  this.name = name;
 }

 public Integer getId() {
  return id;
 }

 public void setId(Integer id) {
  this.id = id;
 }
}
然后新徏一个tmac.xml跟Tmac.java映射h
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="Tmac">
 <typeAlias alias="Tmac" type="enpty.Tmac" />
 
 <resultMap id="Result" class="Tmac">
  <result property="id" column="id"/>
  <result property="name" column="name"/>
  </resultMap>

 <insert id = "insertCust" parameterClass="Tmac">
    INSERT INTO tmac VALUES(#id#,#name#)
 </insert>
</sqlMap>

在新Z个sql-map-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
 <sqlMap resource="enpty/tmac.xml" />
</sqlMapConfig>

新徏一个Spring的配|文件applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

   <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName">
   <value>com.mysql.jdbc.Driver</value>
  </property>
  <property name="url">
   <value>jdbc:mysql://localhost:3306/test</value>
  </property>
  <property name="username">
   <value>root</value>
  </property>
  <property name="password">
   <value>root</value>
  </property>
  <property name="maxWait">
   <value>5</value>
  </property>
 </bean>
 
 <bean id="TransactionManager"
   class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource">
   <ref bean="dataSource"/>
  </property>
 </bean>
 
 <bean id="sqlMapClient"
   class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="/WEB-INF/classes/sql-map-config.xml">
  </property>
  <property name="dataSource">
   <ref bean="dataSource"/>
  </property>
 </bean>
 
 
 <!-- sqlMapClientTemplate是一个模板类 -->
 <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
    <property name="sqlMapClient">
        <ref bean="sqlMapClient"/>
    </property>
 </bean>
 
 <bean id="jsong" class="enpty.Jsong">
    <property name="map">
       <ref bean="sqlMapClientTemplate"/>
    </property>
 </bean>
 </beans>
在徏立一个Jsong.java
public class Jsong {

  @SuppressWarnings("unused")
 private SqlMapClientTemplate map;

 public SqlMapClientTemplate getMap() {
  return map;
 }

 public void setMap(SqlMapClientTemplate map) {
  this.map = map;
 }
 
 public void insert(Tmac aa)
 {
  map.insert("insertCust",aa);
 }
}

在新Z个测试类 Test.java

public class Test{

 /**
  * @param args
  */
 public static void main(String[] args) {
  try
  {
   ApplicationContext fa=new ClassPathXmlApplicationContext("applicationContext.xml");
            Jsong jsong=(Jsong) fa.getBean("jsong");
   
   Tmac aa=new Tmac();
   aa.setId(10);
   aa.setName("jay");
   jsong.insert(aa);
   
  } catch (Exception e) {
   e.printStackTrace();
  }

 }

}

我的数据库是MySql,里面有张表是tmac 里面?个字D?id和name




Jsong 2008-07-17 16:36 发表评论
]]>
jdomhttp://www.aygfsteel.com/jsong/archive/2008/07/17/215527.htmlJsongJsongThu, 17 Jul 2008 08:17:00 GMThttp://www.aygfsteel.com/jsong/archive/2008/07/17/215527.htmlhttp://www.aygfsteel.com/jsong/comments/215527.htmlhttp://www.aygfsteel.com/jsong/archive/2008/07/17/215527.html#Feedback0http://www.aygfsteel.com/jsong/comments/commentRss/215527.htmlhttp://www.aygfsteel.com/jsong/services/trackbacks/215527.html 首先下蝲一个jdom.jarQ把它复制到目的LIB下面
然后写一个测试类
ReadXml .java

package test.xml;

import java.util.List;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

public class ReadXml {

 @SuppressWarnings("unchecked")
 public static void main(String[] args) {
  @SuppressWarnings("unused")
  SAXBuilder sax = new SAXBuilder();
  try
  {
   @SuppressWarnings("unused")
   Document dom=sax.build("test.xml");
   @SuppressWarnings("unused")
   Element el=dom.getRootElement(); //得到根节?br />    
   @SuppressWarnings("unused")
   List list=el.getChildren();//得到el根元素下面所有的子元?br />    
   for(int i=0;i<list.size();i++)
   {
    Element ee=(Element) list.get(i);
    System.out.println(ee.getName());//得到ee元素的名?br />     System.out.println(ee.getAttributeValue("w高"));//得到ee属性的?br />     System.out.println("----------");
    System.out.println(ee.getValue());//得到ee节点下所有元素的?br />       if(ee.getChildText("前?).equals("1"))
      {
       System.out.println(ee.getChildText("火箭"));//得到ee节点下面元素?火箭"的?br />       }
     
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
}

׃自动生成一个test.xml的文?br /> <?xml version="1.0" encoding="UTF-8"?>
<球>
  <麦_ w高="2.02">
    <前?gt;1</前?gt;
    <火箭>62?lt;/火箭>
  </麦_>
  <U比 w高="1.98">
    <得分后卫>8</得分后卫>
    <!--麦_vsU比 no.1-->
    <湖h>81?lt;/湖h>
  </U比>
</球>

下面代码是读取XML中的内容

package test.xml;

import java.io.FileOutputStream;
import java.io.IOException;

import org.jdom.Comment;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

public class WriteXml {

 public static void main(String[] args) {

  @SuppressWarnings("unused")
  Document dom = new Document();
 
  Element students = new Element("球");  //根节?br />   Element s1 = new Element("麦_");   
  Element s2 = new Element("U比");
  Element n1 = new Element("前?);
  Element n2 = new Element("得分后卫");
  Element c1 = new Element("火箭");
  Element c2 = new Element("湖h");
  Comment cc = new Comment("麦_vsU比 no.1"); //CommentcL注释

  n1.setText("1"); //讄n1节点元素的?br />   n2.setText("8");
  c1.setText("62?);
  c2.setText("81?);
  s1.setAttribute("w高", "2.02");  //在s1节点上面加入属性id,id的值是s01
  s2.setAttribute("w高", "1.98");

  s1.addContent(n1);
  s1.addContent(c1);
  s2.addContent(n2);
  s2.addContent(cc);
  s2.addContent(c2);

  students.addContent(s1);//s1节点d到students根节点上
  students.addContent(s2);
  dom.addContent(students);//根节点studentsd到dom对象里面
  XMLOutputter outputter = new XMLOutputter();
  outputter.setFormat(Format.getPrettyFormat());//讄xml中的排版格式
  try {
   outputter.output(dom, new FileOutputStream("test.xml"));
  } catch (IOException ex) {
   ex.printStackTrace();
  }

 }

}



Jsong 2008-07-17 16:17 发表评论
]]>
JDK和JREhttp://www.aygfsteel.com/jsong/archive/2008/07/16/215203.htmlJsongJsongWed, 16 Jul 2008 06:34:00 GMThttp://www.aygfsteel.com/jsong/archive/2008/07/16/215203.htmlhttp://www.aygfsteel.com/jsong/comments/215203.htmlhttp://www.aygfsteel.com/jsong/archive/2008/07/16/215203.html#Feedback0http://www.aygfsteel.com/jsong/comments/commentRss/215203.htmlhttp://www.aygfsteel.com/jsong/services/trackbacks/215203.html阅读全文

Jsong 2008-07-16 14:34 发表评论
]]>
一些常用的DOC命ohttp://www.aygfsteel.com/jsong/archive/2007/12/07/166081.htmlJsongJsongFri, 07 Dec 2007 08:33:00 GMThttp://www.aygfsteel.com/jsong/archive/2007/12/07/166081.htmlhttp://www.aygfsteel.com/jsong/comments/166081.htmlhttp://www.aygfsteel.com/jsong/archive/2007/12/07/166081.html#Feedback0http://www.aygfsteel.com/jsong/comments/commentRss/166081.htmlhttp://www.aygfsteel.com/jsong/services/trackbacks/166081.htmlwinver---------查Windows版本
wmimgmt.msc----打开windows理体系l构(WMI)
wupdmgr--------windows更新E序
wscript--------windows脚本宿主讄
write----------写字?
winmsd---------pȝ信息
wiaacmgr-------扫描仪和照相机向?
winchat--------XP自带局域网聊天

mem.exe--------昄内存使用情况
Msconfig.exe---pȝ配置实用E序
mplayer2-------易widnows media player
mspaint--------d?
mstsc----------q程桌面q接
mplayer2-------媒体播放?
magnify--------攑֤镜实用程?
mmc------------打开控制?
mobsync--------同步命o

dxdiag---------查DirectX信息
drwtsn32------ pȝȝ
devmgmt.msc--- 讑֤理?
dfrg.msc-------盘片整理E序
diskmgmt.msc---盘理实用E序
dcomcnfg-------打开pȝlg服务
ddeshare-------打开DDE׃n讄
dvdplay--------DVD播放?

net stop messenger-----停止信服务
net start messenger----开始信使服?
notepad--------打开C?
nslookup-------|络理的工具向?
ntbackup-------pȝ备䆾和还?
narrator-------屏幕“讲述?#8221;
ntmsmgr.msc----Ud存储理?
ntmsoprq.msc---Ud存储理员操作请?
netstat -an----(TC)命o查接?

syncapp--------创徏一个公文包
sysedit--------pȝ配置~辑?
sigverif-------文g{֐验证E序
sndrec32-------录音?
shrpubw--------创徏׃n文g?
secpol.msc-----本地安全{略
syskey---------pȝ加密Q一旦加密就不能解开Q保护windows xppȝ的双重密?
services.msc---本地服务讄
Sndvol32-------音量控制E序
sfc.exe--------pȝ文g查器
sfc /scannow---windows文g保护

tsshutdn-------60U倒计时关机命?
tourstart------xp介(安装完成后出现的漫游xpE序Q?
taskmgr--------d理?

eventvwr-------事g查看?
eudcedit-------造字E序
explorer-------打开资源理?

packager-------对象包装E序
perfmon.msc----计算机性能监测E序
progman--------E序理?

regedit.exe----注册?
rsop.msc-------l策略结果集
regedt32-------注册表编辑器
rononce -p ----15U关?
regsvr32 /u *.dll----停止dll文gq行
regsvr32 /u zipfldr.dll------取消ZIP支持

cmd.exe--------CMD命o提示W?
chkdsk.exe-----Chkdsk盘?
certmgr.msc----证书理实用E序
calc-----------启动计算?
charmap--------启动字符映射?
cliconfg-------SQL SERVER 客户端网l实用程?
Clipbrd--------剪脓板查看器
conf-----------启动netmeeting
compmgmt.msc---计算机管?
cleanmgr-------垃圾整理
ciadv.msc------索引服务E序

osk------------打开屏幕键盘
odbcad32-------ODBC数据源管理器
oobe/msoobe /a----查XP是否Ȁz?
lusrmgr.msc----本机用户和组
logoff---------注销命o

iexpress-------木马捆绑工具Q系l自?

Nslookup-------IP地址侦测?

fsmgmt.msc-----׃n文g夹管理器

utilman--------辅助工具理?

gpedit.msc-----l策?/p>


run里面的内容可以定制的

定制你的q行输入?
在Windows里面QMicrosoft提供了一个新的快捷启动程序的ҎQ运?
打开[开始]------[q行]Q里面可以直接启动一些特定的E序Q如Q输入notepad.exe启动C本,输入xdict.exe启动金山词霸{等?/p>

启动的原理是什么呢Q很单,在注册表HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp Paths下面Q可以看到很多次U主键,每一个次U主键就对应着一个能够在q行里面输入的内宏V?/p>

以ACDSee.exe主键ZQ右Ҏ2个字W串Q默认对应的是这个程序的l对路径Q而Path对应的是q个E序所处的目录?/p>

定制的方法很单:在App Paths下新Z个不同名的次U主键(例如QSmallfrogs.EXEQ,然后修改双的默认ؓ你要启动的程序的路径Q例如:C:Program FilesMy APPSmallfrogs.EXEQ,然后新徏一个字W串PathQ修改ؓ那个E序所处的目录Q例?:C:Program FilesMy APPQ?/p>

然后可以在q行里面输入QSmallfrogs.EXE来启动C:Program FilesMy APPSmallfrogs.EXEq个E序了?/p>

注意Q系l是*ơ主键的名字来辨认E序的,即你不使用Smallfrogs.EXE建立ơ主键Q而用SSSSS.EXE建立ơ主键Q如果莫MPath的内容和上例一L话,输入SSSSS.EXE启动的程序仍然是C:Program FilesMy APPSmallfrogs.EXEq个E序?/p>

wupdmgr WIDNOWS UPDATE
shutdown -a x解除
about:home 登陆首页
... (三个半角? 我的电脑
dvdplay DVD播放?br /> fsmgmt ׃n控制?br /> 桌面 打开桌面所在文件夹
..Q两点)打开C:documents and Settings
.Q一点)打开「开始」菜?br /> calc 计算?br /> clipbrd 剪脓板查看器
control 打开控制面板
eventvwr 事g查看?br /> mstsc q程桌面

常用命oQmsconfig Q?regedit Q?internat Qsystemtray Qtemp Qsfc Qdfrg



Jsong 2007-12-07 16:33 发表评论
]]>
在tomcat中配|域?/title><link>http://www.aygfsteel.com/jsong/archive/2007/11/06/158510.html</link><dc:creator>Jsong</dc:creator><author>Jsong</author><pubDate>Tue, 06 Nov 2007 05:14:00 GMT</pubDate><guid>http://www.aygfsteel.com/jsong/archive/2007/11/06/158510.html</guid><wfw:comment>http://www.aygfsteel.com/jsong/comments/158510.html</wfw:comment><comments>http://www.aygfsteel.com/jsong/archive/2007/11/06/158510.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jsong/comments/commentRss/158510.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jsong/services/trackbacks/158510.html</trackback:ping><description><![CDATA[1.首先,安装tomcat服务?<br /> 2.修改Tomcat/confi/Server.xml: <br /> 修改?<br /> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"> <br /> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="intel_log." suffix=".txt" timestamp="true"/> <br /> </Host> <br /> -----------------------------------<br /> 修改?        //随便?取你自己定义的域?br /> <Host name="<a debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"> <br /> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="intel_log." suffix=".txt" timestamp="true"/> <br /> </Host>                docBase="目的\?<br /> <Context path="" docBase="D:\WebData\ACO" debug="0" <br /> reloadable="true" crossContext="true"> <br /> </Context> <br /> <br /> 我還在本地電腦C:\WINNT\system32\drivers\etc\Hosts配置了該域名H如下﹕ <br /> <br /> 127.0.0.1 localhost <br /> *.*.*.*(表示我的IP) chenxi.foxconn.com <br /> 在URL中?<a >www.aa.com</a> 時不能瀏覽Web頁面H而再加上Tomcat 端口可以了(<a >www.aa.com:8080</a>).<br /> 在Tomcat 5.0\conf\server.xml?<br /> <Connector <br /> port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" <br /> enableLookups="false" redirectPort="8443" acceptCount="100" <br /> debug="0" connectionTimeout="20000" <br /> disableUploadTimeout="true" /> <br /> 改ؓ <br /> <Connector <br /> port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" <br /> enableLookups="false" redirectPort="8443" acceptCount="100" <br /> debug="0" connectionTimeout="20000" <br /> disableUploadTimeout="true" /> <br /> 重新启动tomcat可以了,輸入www.aa.com 可以瀏覽Web頁面問題 <img src ="http://www.aygfsteel.com/jsong/aggbug/158510.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jsong/" target="_blank">Jsong</a> 2007-11-06 13:14 <a href="http://www.aygfsteel.com/jsong/archive/2007/11/06/158510.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring2.X中的AOP的?/title><link>http://www.aygfsteel.com/jsong/archive/2007/10/25/155873.html</link><dc:creator>Jsong</dc:creator><author>Jsong</author><pubDate>Thu, 25 Oct 2007 07:00:00 GMT</pubDate><guid>http://www.aygfsteel.com/jsong/archive/2007/10/25/155873.html</guid><wfw:comment>http://www.aygfsteel.com/jsong/comments/155873.html</wfw:comment><comments>http://www.aygfsteel.com/jsong/archive/2007/10/25/155873.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jsong/comments/commentRss/155873.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jsong/services/trackbacks/155873.html</trackback:ping><description><![CDATA[和Spring1.X相比,Spring2.X使用AspectJ的语法来声明AOP.本h也真在学?<br /> <br /> <p>package com.springinaction.chapter01.knight;</p> <p>public class Tempimp implements Temp {</p> <p> public void temp() {<br />   System.out.println("jsong");</p> <p> }</p> <p>}</p> <br /> <br /> <p><?xml version="1.0" encoding="UTF-8"?></p> <p><beans xmlns="http://www.springframework.org/schema/beans"<br />  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />  xmlns:aop="http://www.springframework.org/schema/aop"<br />  xsi:schemaLocation="http://www.springframework.org/schema/beans <br />             http://www.springframework.org/schema/beans/spring-beans-2.0.xsd<br />           http://www.springframework.org/schema/aop <br />             http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"></p> <p> <br />  <br />  <bean  id="aa" class="com.springinaction.chapter01.knight.Tempimp"/></p> <p><br />  <aop:config>      <br />   <aop:aspect id ="logAspect" ref="aa">     <br />                                                声明一个切?id="随便定义"  ref="引用上面的bean(aa)"<br />        <aop:pointcut id="businessService" expression = "execution(* springinaction.chapter01.knight.Tempimp.temp(..))" />  <br />                                                声明一个切入点<br />        <aop:around pointcut-ref="businessService"   method="intercept"/>   <br />                                                通知<br />         <aop:after pointcut-ref = "businessService" method ="temp"/>  <br />                                               声明通知<br /> <br />        </aop:aspect><br />     </aop:config> <br />  <br /> </beans></p> l果q是会调用temp()Ҏ.打印出jsong?br /> 现在q在l箋学些spring2.X。希望大家多多指?有什么问?大家互相学习<br /> <img src ="http://www.aygfsteel.com/jsong/aggbug/155873.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jsong/" target="_blank">Jsong</a> 2007-10-25 15:00 <a href="http://www.aygfsteel.com/jsong/archive/2007/10/25/155873.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>spring中的调度?Quartz)http://www.aygfsteel.com/jsong/archive/2007/10/25/155852.htmlJsongJsongThu, 25 Oct 2007 05:55:00 GMThttp://www.aygfsteel.com/jsong/archive/2007/10/25/155852.htmlhttp://www.aygfsteel.com/jsong/comments/155852.htmlhttp://www.aygfsteel.com/jsong/archive/2007/10/25/155852.html#Feedback1http://www.aygfsteel.com/jsong/comments/commentRss/155852.htmlhttp://www.aygfsteel.com/jsong/services/trackbacks/155852.html

<bean name="caa" class="cn.market.quartz.Caa" singleton="false">
 <property name="marketMgr">
  <ref bean="marketManager" />
 </property>
</bean>


<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <!--targetObject 是MethodInvokingJobDetailFactoryBean的一个属?->
 <property name="targetObject" ref="caa" />  <!--caa是一个生成执行类.里面写的操作数据库的Ҏ-->
 <property name="targetMethod" value="creat" />    <!--creat是caa中的一个方?是操作Ҏ)-->
 <property name="concurrent" value="false" />
</bean>

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
 <property name="jobDetail" ref="jobDetail" />
 <property name="cronExpression" value="0 0 8-18 * * ?" /> <!--表示从早?点到晚上6?每一个小时执行一?->
</bean>
   
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
 <property name="triggers">
  <list>
   <ref bean="cronTrigger" />
  </list>
 </property>
</bean>



Jsong 2007-10-25 13:55 发表评论
]]>
Struts中的ACTIONhttp://www.aygfsteel.com/jsong/archive/2007/10/25/155846.htmlJsongJsongThu, 25 Oct 2007 05:33:00 GMThttp://www.aygfsteel.com/jsong/archive/2007/10/25/155846.htmlhttp://www.aygfsteel.com/jsong/comments/155846.htmlhttp://www.aygfsteel.com/jsong/archive/2007/10/25/155846.html#Feedback2http://www.aygfsteel.com/jsong/comments/commentRss/155846.htmlhttp://www.aygfsteel.com/jsong/services/trackbacks/155846.html org.apache.struts.action.Action,                  --父类
org.apache.struts.actions.DispatchAction,       子类
org.apache.struts.actions.LookupDispatchAction,  子类
org.apache.struts.actions.MappingDispatchAction, 子类
DispatchAction, LookupDispatchAction, MappingDispatchAction都是l承的Actionc?

DispatchAction
定义

public abstract class DispatchAction extends Action
q是一个抽象的Action,它会Ҏrequest 中的parameter来执行相应的Ҏ。通个q个Actioncd以将不同的Action集中C个Action文g中来?/p>

Struts-config.xml:

<action path="/saveSubscription" type="org.apache.struts.actions.DispatchAction" name="subscriptionForm" scope="request" input="/subscription.jsp" parameter="method"/>

在Action中要有相应的Ҏ:

Public class demoAction extends DispatchAction{

public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

public ActionForward insert(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

}

你就可以通过q样的方法来讉K你的E序:


http://localhost:8080/myapp/saveSubscription.do?method=update


如果parameter中参CؓI,则执行Action中unspecifiedҎ


LookupDispatchAction
public abstract class LookupDispatchAction extends DispatchAction
通过q个Action抽象cȝ承DispatchActionQ它的相应方法的执行?ActionMapping中parameter属性决定。它适合在一个form中有很多按钮Q按不同的按钮则执行不同的操作?/p>

struts-config.xml:

<action path="/test"

type="org.example.MyAction"

name="MyForm"

scope="request"

input="/test.jsp"

parameter="method"/>

ApplicationResources.properties:


button.add=Add Record

button.delete=Delete Record

JSP:


<html:form action="/test">

<html:submit property="method">

<bean:message key="button.add"/>

</html:submit>

<html:submit property="method">

<bean:message key="button.delete"/>

</html:submit>

</html:form>

在Action 中必d现getKeyMethodMap:


protected Map getKeyMethodMap() {

Map map = new HashMap();

map.put("button.add", "add");

map.put("button.delete", "delete");

return map;

}


public ActionForward add(ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

// do add

return mapping.findForward("success");

}


public ActionForward delete(ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

// do delete

return mapping.findForward("success");

}


MappingDispatchAction
public class MappingDispatchAction extends DispatchAction
它的相应Ҏ的执行由 ActionMapping中parameter名决?注意q里和LookupDispatchAction不同QLookupDispatchAction的相应方法的执行?ActionMapping中parameter属性决定,


struts-config.xml:

 

<action path="/saveSubscription"

type="org.example.SubscriptionAction"

name="subscriptionForm"

scope="request"

input="/subscription.jsp"

parameter="method"/>

Action:


public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

for which you would create corresponding <action> configurations that reference this class:

 

<action path="/createSubscription"

type="org.example.SubscriptionAction"

parameter="create">

<forward name="success" path="/editSubscription.jsp"/>

</action>


<action path="/editSubscription"

type="org.example.SubscriptionAction"

parameter="edit">

<forward name="success" path="/editSubscription.jsp"/>

</action>


<action path="/saveSubscription"

type="org.example.SubscriptionAction"

parameter="save"

name="subscriptionForm"

validate="true"

input="/editSubscription.jsp"

scope="request">

<forward name="success" path="/savedSubscription.jsp"/>

</action>


<action path="/deleteSubscription"

type="org.example.SubscriptionAction"

name="subscriptionForm"

scope="request"

input="/subscription.jsp"

parameter="delete">

<forward name="success" path="/deletedSubscription.jsp"/>

</action>


<action path="/listSubscriptions"

type="org.example.SubscriptionAction"

parameter="list">

<forward name="success" path="/subscriptionList.jsp"/>

</action>


DispatchAction,LookupDispatchAction,MappingDispatchAction
1) DispatchAction是在struts-config中用parameter参数配置一个表单字D名,q个字段的值就是最l替代execute被调用的Ҏ. 例如parameter="method"而request.getParameter("method")="save"Q其?save"是MethodName。struts的请求将Ҏparameter被分发到"save"或?edit"或者什么。但是有一点,save()或者edit(){方法的声明和execute必须一模一栗?/p>

2) LookupDispatchActionl承DispatchAction, 用于对同一个页面上的多个submit按钮q行不同的响应。其原理是,首先用MessageResource按钮的文本和ResKey相关联,例如button.save=保存Q然后再复写getKeyMethodMap(), ResKey和MethodName对应h, 例如map.put("button.save", "save"); 光|方法和DispatchAction是一L, 使用时要q么?

3) MappingDispatchAction?.2新加? 也承自DispatchAction. 它实现的功能和上面两个区别较? 是通过struts-config.xml多个action-mapping映射到同一个Actioncȝ不同Ҏ? 典型的配|就?


然后UserActionl承MappingDispatchActionQ其中有Q?br /> public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{方?/p>

可以看到, 不管怎么变化, 其实q些c都是把executel分解开, 不管是save, editq是其他什么方? 其实都是和原来的execute是等L, save和edit之间没有M直接的关p? 而事实呢Q它们是同一个业务模型的两种不同操作?我觉得这是一个问题,对于save和editq两U请? 我后台逻辑有可能只是调用service的方法那一句不一P其他代码是完全一致的(例如错误处理, 日志记录{?。因此我惛_了这个小东西Q在executeҎ内部q行局部分?/p>



Jsong 2007-10-25 13:33 发表评论
]]>
自定义报?/title><link>http://www.aygfsteel.com/jsong/archive/2007/10/25/155844.html</link><dc:creator>Jsong</dc:creator><author>Jsong</author><pubDate>Thu, 25 Oct 2007 05:26:00 GMT</pubDate><guid>http://www.aygfsteel.com/jsong/archive/2007/10/25/155844.html</guid><wfw:comment>http://www.aygfsteel.com/jsong/comments/155844.html</wfw:comment><comments>http://www.aygfsteel.com/jsong/archive/2007/10/25/155844.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jsong/comments/commentRss/155844.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jsong/services/trackbacks/155844.html</trackback:ping><description><![CDATA[<p>用ASP.net做过开发的人都知道.?net中做报表很简? 可是,在java中如何解x表问题了.其实在java中用报表也不是什么难?可以使用<span id="wmqeeuq" class="txtstyle">FineReportq个产品.它可以实C些复杂的报表问题.它可以生成饼状图和柱形图.{复杂的报表模板.q样可以l开发h员提供一个很好的q_.</span><br /> <br /> <span id="wmqeeuq" class="txtstyle">FineReport软g是帆软YӞ中国Q公司自ȝ发的一ƾ企业的报表工兯YӞ针对复杂格式的报表数据及Web报表的展玎ͼFineReport提供了分l报表来l承SQL型报表工兯Y件的快速做单格式报表的优点Q提供了电子表格来承Cell型报表工兯Y件的可以做极度没有规则的复杂格式报表的优点,又创新性的提供?#8220;Excel+l定数据?#8221;形式的自由报表,通过多源分片、不规则分组、双向扩展来L拖拽做复杂格式的报表Q做报表从此不再需要编写复杂的SQL语句和做大量的前期数据准备了Q不仅不需要编E而且大大降低了报表后期的l护量,制作报表的效率提高了一个数量.它分为报?表单设计器,报表/表单服务?<br /> <br /> 首先Q要?a >http://www.finereport.com/cn/index.html</a>下蝲相关软g.安装完成?打开报表设计?<br />   </p> <p><span style="font-family: 宋体">一般来_一个完整的报表设计程Q大体分为如下几个步骤:</span></p> <p style="margin-left: 26.25pt; text-indent: -26.25pt"><span style="font-size: 12pt; color: red; font-family: 宋体">打开设计?/span><span style="font-size: 15pt; color: red; font-family: Wingdings"><span style="font-size: 12pt"><span style="color: red; font-family: Wingdings">à</span><span style="color: red; font-family: 宋体">配置数据?/span><span style="color: red; font-family: Wingdings">à</span><span style="color: red; font-family: 宋体">新徏报表</span><span style="color: red; font-family: Wingdings">à</span><span style="color: red; font-family: 宋体">定义U有数据?/span><span style="color: red; font-family: Wingdings">à</span><span style="color: red; font-family: 宋体">报表设计</span><span style="color: red; font-family: Wingdings">à</span><span style="color: red; font-family: 宋体">预揽报表</span><span style="color: red; font-family: Wingdings">à</span><span style="color: red; font-family: 宋体">发布报表<br /> <br /> 具体的步骤我׃多说?该Y件有很详l的帮助说明文档.可参考它的说明文?如有不清楚的地方.可以留言或于我联p?..我这里有做好的实?可供大家参?.</span></span></span></span></p> <img src ="http://www.aygfsteel.com/jsong/aggbug/155844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jsong/" target="_blank">Jsong</a> 2007-10-25 13:26 <a href="http://www.aygfsteel.com/jsong/archive/2007/10/25/155844.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>URLrewritehttp://www.aygfsteel.com/jsong/archive/2007/10/25/155827.htmlJsongJsongThu, 25 Oct 2007 04:44:00 GMThttp://www.aygfsteel.com/jsong/archive/2007/10/25/155827.htmlhttp://www.aygfsteel.com/jsong/comments/155827.htmlhttp://www.aygfsteel.com/jsong/archive/2007/10/25/155827.html#Feedback0http://www.aygfsteel.com/jsong/comments/commentRss/155827.htmlhttp://www.aygfsteel.com/jsong/services/trackbacks/155827.html1.首先下蝲1个urlrewrite-3.0.4.zip的压~包.把它解压.?lib/下面扑ֈurlrewrite-3.0.4.jar文g.
2.打开eclipse,先徏立一个Web目.然后把这个urlrewrite-3.0.4.jar复制到项目重中的lib文g下面.
3.修改web.xml文g.?lt;web-app></web-app>标签中加入过滤器
<filter>
       <filter-name>UrlRewriteFilter</filter-name>
       <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
       <filter-name>UrlRewriteFilter</filter-name>
       <url-pattern>/*</url-pattern>
</filter-mapping>

4.在web-inf目录下徏立一个urlrewrite.xml.在该文g里添加以下代?br /> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
        "http://tuckey.org/res/dtds/urlrewrite3.0.dtd">
<urlrewrite>
 <rule>
   <from>/tmac/(.*).html</from>    tmac:可以随便取名?但最好是英文   后缀?html可以随便?例如.aa,.vv{?一定要?br />    <to>/index.jsp?id=$1</to>       index.jsp:是我自己新徏的JSP文g.  id:是参数名,参数名可以随便定?  id=$1是对应的格式化表辑ּ
 </rule>
</urlrewrite>
5.然后在webroot下面建立1个index.jsp在jsp里加?br /> <%  System.out.println(request.getParameter("id")); %>
看看id打出来是个什么内?

6.在启动tomcat服务?在iE上输入http://localhost:8080/工程?tmac/a.html/可以看到效?在这?./tmac/a.html是根据urlrewrite.xml里面from标签的值来?一定要和from标签的值匹?/p>

Jsong 2007-10-25 12:44 发表评论
]]>
վ֩ģ壺 | ֹ| ߴ| | | | ˳| | Ͷ| ˳| | | | | | ʯ| | ƽ| ̫| û| | | | Ҫ| ݳ| ٲ| | | | | Ϻӿ| | | | ɽ| ԰| | | ɳ| | Ͼ|