锘??xml version="1.0" encoding="utf-8" standalone="yes"?> public Integer id; public String getName() { public void setName(String name) { public Integer getId() { public void setId(Integer id) { <insert id = "insertCust" parameterClass="Tmac"> 鍦ㄦ柊寤轟竴涓猻ql-map-config.xml <bean id="dataSource" @SuppressWarnings("unused") public SqlMapClientTemplate getMap() { public void setMap(SqlMapClientTemplate map) { 鍦ㄦ柊寤轟竴涓祴璇曠被 Test.java public class Test{ /** } } 鎴戠殑鏁版嵁搴撴槸MySql,閲岄潰鏈夊紶琛ㄦ槸tmac 閲岄潰鏈?涓瓧孌?id鍜宯ame package test.xml; import java.util.List; import org.jdom.Document; public class ReadXml { @SuppressWarnings("unchecked") package test.xml; import java.io.FileOutputStream; import org.jdom.Comment; public class WriteXml { public static void main(String[] args) { @SuppressWarnings("unused") n1.setText("1"); //璁劇疆n1鑺傜偣鍏冪礌鐨勫?br />
n2.setText("8"); s1.addContent(n1); students.addContent(s1);//灝唖1鑺傜偣娣誨姞鍒皊tudents鏍硅妭鐐逛笂 } }
鍐欎竴涓狿OJO 瀹炰綋bean 瀹炵幇搴忓垪鍖栨帴鍙?br />
public class Tmac implements Serializable {
public String name;
return name;
}
this.name = name;
}
return id;
}
this.id = id;
}
}
鐒跺悗鏂板緩涓涓猼mac.xml璺烼mac.java鏄犲皠璧鋒潵
<?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 INTO tmac VALUES(#id#,#name#)
</insert>
</sqlMap>
<?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>
鏂板緩涓涓猄pring鐨勯厤緗枃浠禷pplicationContext.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">
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>
鍦ㄥ緩绔嬩竴涓狫song.java
public class Jsong {
private SqlMapClientTemplate map;
return map;
}
this.map = map;
}
public void insert(Tmac aa)
{
map.insert("insertCust",aa);
}
}
* @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();
}
]]>
鐒跺悗鍐欎竴涓祴璇曠被
ReadXml .java
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
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("韜珮"));//寰楀埌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();
}
}
}
灝變細鑷姩鐢熸垚涓涓猼est.xml鐨勬枃浠?br />
<?xml version="1.0" encoding="UTF-8"?>
<綃悆>
<楹﹁開 韜珮="2.02">
<灝忓墠閿?gt;1</灝忓墠閿?gt;
<鐏>62鍒?lt;/鐏>
</楹﹁開>
<縐戞瘮 韜珮="1.98">
<寰楀垎鍚庡崼>8</寰楀垎鍚庡崼>
<!--楹﹁開vs縐戞瘮 no.1-->
<婀栦漢>81鍒?lt;/婀栦漢>
</縐戞瘮>
</綃悆>
涓嬮潰浠g爜鏄鍙朮ML涓殑鍐呭
import java.io.IOException;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
Document dom = new Document();
Element students = new Element("綃悆"); //鏍硅妭鐐?br />
Element s1 = new Element("楹﹁開");
Element s2 = new Element("縐戞瘮");
Element n1 = new Element("灝忓墠閿?);
Element n2 = new Element("寰楀垎鍚庡崼");
Element c1 = new Element("鐏");
Element c2 = new Element("婀栦漢");
Comment cc = new Comment("楹﹁開vs縐戞瘮 no.1"); //Comment綾繪槸娉ㄩ噴
c1.setText("62鍒?);
c2.setText("81鍒?);
s1.setAttribute("韜珮", "2.02"); //鍦╯1鑺傜偣涓婇潰鍔犲叆灞炴d,id鐨勫兼槸s01
s2.setAttribute("韜珮", "1.98");
s1.addContent(c1);
s2.addContent(n2);
s2.addContent(cc);
s2.addContent(c2);
students.addContent(s2);
dom.addContent(students);//灝嗘牴鑺傜偣students娣誨姞鍒癲om瀵硅薄閲岄潰
XMLOutputter outputter = new XMLOutputter();
outputter.setFormat(Format.getPrettyFormat());//璁劇疆xml涓殑鎺掔増鏍煎紡
try {
outputter.output(dom, new FileOutputStream("test.xml"));
} catch (IOException ex) {
ex.printStackTrace();
}
]]>
]]>
wmimgmt.msc----鎵撳紑windows綆$悊浣撶郴緇撴瀯(WMI)
wupdmgr--------windows鏇存柊紼嬪簭
wscript--------windows鑴氭湰瀹夸富璁劇疆
write----------鍐欏瓧鏉?
winmsd---------緋葷粺淇℃伅
wiaacmgr-------鎵弿浠拰鐓х浉鏈哄悜瀵?
winchat--------XP鑷甫灞鍩熺綉鑱婂ぉ
mem.exe--------鏄劇ず鍐呭瓨浣跨敤鎯呭喌
Msconfig.exe---緋葷粺閰嶇疆瀹炵敤紼嬪簭
mplayer2-------綆鏄搘idnows media player
mspaint--------鐢誨浘鏉?
mstsc----------榪滅▼妗岄潰榪炴帴
mplayer2-------濯掍綋鎾斁鏈?
magnify--------鏀懼ぇ闀滃疄鐢ㄧ▼搴?
mmc------------鎵撳紑鎺у埗鍙?
mobsync--------鍚屾鍛戒護
dxdiag---------媯鏌irectX淇℃伅
drwtsn32------ 緋葷粺鍖葷敓
devmgmt.msc--- 璁懼綆$悊鍣?
dfrg.msc-------紓佺洏紕庣墖鏁寸悊紼嬪簭
diskmgmt.msc---紓佺洏綆$悊瀹炵敤紼嬪簭
dcomcnfg-------鎵撳紑緋葷粺緇勪歡鏈嶅姟
ddeshare-------鎵撳紑DDE鍏變韓璁劇疆
dvdplay--------DVD鎾斁鍣?
net stop messenger-----鍋滄淇′嬌鏈嶅姟
net start messenger----寮濮嬩俊浣挎湇鍔?
notepad--------鎵撳紑璁頒簨鏈?
nslookup-------緗戠粶綆$悊鐨勫伐鍏峰悜瀵?
ntbackup-------緋葷粺澶囦喚鍜岃繕鍘?
narrator-------灞忓箷“璁茶堪浜?#8221;
ntmsmgr.msc----縐誨姩瀛樺偍綆$悊鍣?
ntmsoprq.msc---縐誨姩瀛樺偍綆$悊鍛樻搷浣滆姹?
netstat -an----(TC)鍛戒護媯鏌ユ帴鍙?
syncapp--------鍒涘緩涓涓叕鏂囧寘
sysedit--------緋葷粺閰嶇疆緙栬緫鍣?
sigverif-------鏂囦歡絳懼悕楠岃瘉紼嬪簭
sndrec32-------褰曢煶鏈?
shrpubw--------鍒涘緩鍏變韓鏂囦歡澶?
secpol.msc-----鏈湴瀹夊叏絳栫暐
syskey---------緋葷粺鍔犲瘑錛屼竴鏃﹀姞瀵嗗氨涓嶈兘瑙e紑錛屼繚鎶indows xp緋葷粺鐨勫弻閲嶅瘑鐮?
services.msc---鏈湴鏈嶅姟璁劇疆
Sndvol32-------闊抽噺鎺у埗紼嬪簭
sfc.exe--------緋葷粺鏂囦歡媯鏌ュ櫒
sfc /scannow---windows鏂囦歡淇濇姢
tsshutdn-------60縐掑掕鏃跺叧鏈哄懡浠?
tourstart------xp綆浠嬶紙瀹夎瀹屾垚鍚庡嚭鐜扮殑婕父xp紼嬪簭錛?
taskmgr--------浠誨姟綆$悊鍣?
eventvwr-------浜嬩歡鏌ョ湅鍣?
eudcedit-------閫犲瓧紼嬪簭
explorer-------鎵撳紑璧勬簮綆$悊鍣?
packager-------瀵硅薄鍖呰紼嬪簭
perfmon.msc----璁$畻鏈烘ц兘鐩戞祴紼嬪簭
progman--------紼嬪簭綆$悊鍣?
regedit.exe----娉ㄥ唽琛?
rsop.msc-------緇勭瓥鐣ョ粨鏋滈泦
regedt32-------娉ㄥ唽琛ㄧ紪杈戝櫒
rononce -p ----15縐掑叧鏈?
regsvr32 /u *.dll----鍋滄dll鏂囦歡榪愯
regsvr32 /u zipfldr.dll------鍙栨秷ZIP鏀寔
cmd.exe--------CMD鍛戒護鎻愮ず絎?
chkdsk.exe-----Chkdsk紓佺洏媯鏌?
certmgr.msc----璇佷功綆$悊瀹炵敤紼嬪簭
calc-----------鍚姩璁$畻鍣?
charmap--------鍚姩瀛楃鏄犲皠琛?
cliconfg-------SQL SERVER 瀹㈡埛绔綉緇滃疄鐢ㄧ▼搴?
Clipbrd--------鍓創鏉挎煡鐪嬪櫒
conf-----------鍚姩netmeeting
compmgmt.msc---璁$畻鏈虹鐞?
cleanmgr-------鍨冨溇鏁寸悊
ciadv.msc------绱㈠紩鏈嶅姟紼嬪簭
osk------------鎵撳紑灞忓箷閿洏
odbcad32-------ODBC鏁版嵁婧愮鐞嗗櫒
oobe/msoobe /a----媯鏌P鏄惁嬋媧?
lusrmgr.msc----鏈満鐢ㄦ埛鍜岀粍
logoff---------娉ㄩ攢鍛戒護
iexpress-------鏈ㄩ┈鎹嗙粦宸ュ叿錛岀郴緇熻嚜甯?
Nslookup-------IP鍦板潃渚︽祴鍣?
fsmgmt.msc-----鍏變韓鏂囦歡澶圭鐞嗗櫒
utilman--------杈呭姪宸ュ叿綆$悊鍣?
gpedit.msc-----緇勭瓥鐣?/p>
run閲岄潰鐨勫唴瀹瑰彲浠ュ畾鍒剁殑
瀹氬埗浣犵殑榪愯杈撳叆妗?
鍦╓indows閲岄潰錛孧icrosoft鎻愪緵浜嗕竴涓柊鐨勫揩鎹峰惎鍔ㄧ▼搴忕殑鏂規硶錛氳繍琛?
鎵撳紑[寮濮媇------[榪愯]錛岄噷闈㈠彲浠ョ洿鎺ュ惎鍔ㄤ竴浜涚壒瀹氱殑紼嬪簭錛屽錛氳緭鍏otepad.exe鍚姩璁頒簨鏈紝杈撳叆xdict.exe鍚姩閲戝北璇嶉湼絳夌瓑銆?/p>
鍚姩鐨勫師鐞嗘槸浠涔堝憿錛熷緢綆鍗曪紝鍦ㄦ敞鍐岃〃HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp Paths涓嬮潰錛屽彲浠ョ湅鍒板緢澶氭綰т富閿紝姣忎竴涓綰т富閿氨瀵瑰簲鐫涓涓兘澶熷湪榪愯閲岄潰杈撳叆鐨勫唴瀹廣?/p>
浠CDSee.exe涓婚敭涓轟緥錛氬彸杈規湁2涓瓧絎︿覆錛岄粯璁ゅ搴旂殑鏄繖涓▼搴忕殑緇濆璺緞錛岃孭ath瀵瑰簲鐨勬槸榪欎釜紼嬪簭鎵澶勭殑鐩綍銆?/p>
瀹氬埗鐨勬柟娉曞緢綆鍗曪細鍦ˋpp Paths涓嬫柊寤轟竴涓笉鍚屽悕鐨勬綰т富閿紙渚嬪錛歋mallfrogs.EXE錛夛紝鐒跺悗淇敼鍙寵竟鐨勯粯璁や負浣犺鍚姩鐨勭▼搴忕殑璺緞錛堜緥濡傦細C:Program FilesMy APPSmallfrogs.EXE錛夛紝鐒跺悗鏂板緩涓涓瓧絎︿覆Path錛屼慨鏀逛負閭d釜紼嬪簭鎵澶勭殑鐩綍錛堜緥濡?:C:Program FilesMy APP錛夈?/p>
鐒跺悗灝卞彲浠ュ湪榪愯閲岄潰杈撳叆錛歋mallfrogs.EXE鏉ュ惎鍔–:Program FilesMy APPSmallfrogs.EXE榪欎釜紼嬪簭浜嗐?/p>
娉ㄦ剰錛佺郴緇熸槸*嬈$駭涓婚敭鐨勫悕瀛楁潵杈ㄨ紼嬪簭鐨勶紝鍗充嬌浣犱笉浣跨敤Smallfrogs.EXE寤虹珛嬈$駭涓婚敭錛岃屼嬌鐢⊿SSSS.EXE寤虹珛嬈$駭涓婚敭錛屽鏋滆帿浠諱綍Path鐨勫唴瀹瑰拰涓婁緥涓鏍風殑璇濓紝杈撳叆SSSSS.EXE鍚姩鐨勭▼搴忎粛鐒舵槸C:Program FilesMy APPSmallfrogs.EXE榪欎釜紼嬪簭銆?/p>
wupdmgr WIDNOWS UPDATE
shutdown -a 鍏蟲満瑙i櫎
about:home 鐧婚檰棣栭〉
... (涓変釜鍗婅鐐? 鎴戠殑鐢佃剳
dvdplay DVD鎾斁鍣?br />
fsmgmt 鍏變韓鎺у埗鍙?br />
妗岄潰 鎵撳紑妗岄潰鎵鍦ㄦ枃浠跺す
..錛堜袱鐐癸級鎵撳紑C:documents and Settings
.錛堜竴鐐癸級鎵撳紑銆屽紑濮嬨嶈彍鍗?br />
calc 璁$畻鍣?br />
clipbrd 鍓創鏉挎煡鐪嬪櫒
control 鎵撳紑鎺у埗闈㈡澘
eventvwr 浜嬩歡鏌ョ湅鍣?br />
mstsc 榪滅▼妗岄潰
甯哥敤鍛戒護錛歮sconfig 錛?regedit 錛?internat 錛宻ystemtray 錛宼emp 錛宻fc 錛宒frg
package com.springinaction.chapter01.knight;
public class Tempimp implements Temp {
public void temp() {
System.out.println("jsong");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="aa" class="com.springinaction.chapter01.knight.Tempimp"/>
<aop:config>
<aop:aspect id ="logAspect" ref="aa">
澹版槑涓涓垏闈?id="闅忎究瀹氫箟" ref="寮曠敤涓婇潰鐨刡ean(aa)"
<aop:pointcut id="businessService" expression = "execution(* springinaction.chapter01.knight.Tempimp.temp(..))" />
澹版槑涓涓垏鍏ョ偣
<aop:around pointcut-ref="businessService" method="intercept"/>
閫氱煡
<aop:after pointcut-ref = "businessService" method ="temp"/>
澹版槑閫氱煡
</aop:aspect>
</aop:config>
</beans>
<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 鏄疢ethodInvokingJobDetailFactoryBean鐨勪竴涓睘鎬?->
<property name="targetObject" ref="caa" /> <!--caa鏄竴涓敓鎴愭墽琛岀被.閲岄潰鍐欑殑鎿嶄綔鏁版嵁搴撶殑鏂規硶-->
<property name="targetMethod" value="creat" /> <!--creat鏄痗aa涓殑涓涓柟娉?灝辨槸鎿嶄綔鏂規硶)-->
<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>
DispatchAction
瀹氫箟
public abstract class DispatchAction extends Action
榪欐槸涓涓娊璞$殑Action,瀹冧細鏍規嵁request 涓殑parameter鏉ユ墽琛岀浉搴旂殑鏂規硶銆傞氫釜榪欎釜Action綾誨彲浠ュ皢涓嶅悓鐨凙ction闆嗕腑鍒頒竴涓狝ction鏂囦歡涓潵銆?/p>
Struts-config.xml:
<action path="/saveSubscription" type="org.apache.struts.actions.DispatchAction" name="subscriptionForm" scope="request" input="/subscription.jsp" parameter="method"/>
鍦ˋction涓鏈夌浉搴旂殑鏂規硶:
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
}
浣犲氨鍙互閫氳繃榪欐牱鐨勬柟娉曟潵璁塊棶浣犵殑紼嬪簭:
http://localhost:8080/myapp/saveSubscription.do?method=update
濡傛灉parameter涓弬鏁頒負絀猴紝鍒欐墽琛孉ction涓璾nspecified鏂規硶
LookupDispatchAction
public abstract class LookupDispatchAction extends DispatchAction
閫氳繃榪欎釜Action鎶借薄綾葷戶鎵緿ispatchAction錛屽畠鐨勭浉搴旀柟娉曠殑鎵ц鐢?ActionMapping涓璸arameter灞炴у喅瀹氥傚畠閫傚悎鍦ㄤ竴涓猣orm涓湁寰堝鎸夐挳錛屾寜涓嶅悓鐨勬寜閽垯鎵ц涓嶅悓鐨勬搷浣溿?/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>
鍦ˋction 涓繀欏誨疄鐜癵etKeyMethodMap:
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涓璸arameter鍚嶅喅瀹?娉ㄦ剰榪欓噷鍜孡ookupDispatchAction涓嶅悓錛孡ookupDispatchAction鐨勭浉搴旀柟娉曠殑鎵ц鐢?ActionMapping涓璸arameter灞炴у喅瀹氾紝
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灝辨槸鍦╯truts-config涓敤parameter鍙傛暟閰嶇疆涓涓〃鍗曞瓧孌靛悕,榪欎釜瀛楁鐨勫煎氨鏄渶緇堟浛浠xecute琚皟鐢ㄧ殑鏂規硶. 渚嬪parameter="method"鑰宺equest.getParameter("method")="save"錛屽叾涓?save"灝辨槸MethodName銆俿truts鐨勮姹傚皢鏍規嵁parameter琚垎鍙戝埌"save"鎴栬?edit"鎴栬呬粈涔堛備絾鏄湁涓鐐癸紝save()鎴栬卐dit()絳夋柟娉曠殑澹版槑鍜宔xecute蹇呴』涓妯′竴鏍楓?/p>
2) LookupDispatchAction緇ф壙DispatchAction, 鐢ㄤ簬瀵瑰悓涓涓〉闈笂鐨勫涓猻ubmit鎸夐挳榪涜涓嶅悓鐨勫搷搴斻傚叾鍘熺悊鏄紝棣栧厛鐢∕essageResource灝嗘寜閽殑鏂囨湰鍜孯esKey鐩稿叧鑱旓紝渚嬪button.save=淇濆瓨錛涚劧鍚庡啀澶嶅啓getKeyMethodMap(), 灝哛esKey鍜孧ethodName瀵瑰簲璧鋒潵, 渚嬪map.put("button.save", "save"); 鍏墮厤緗柟娉曞拰DispatchAction鏄竴鏍風殑, 浣跨敤鏃惰榪欎箞鍐?
3) MappingDispatchAction鏄?.2鏂板姞鐨? 涔熺戶鎵胯嚜DispatchAction. 瀹冨疄鐜扮殑鍔熻兘鍜屼笂闈袱涓尯鍒緝澶? 鏄氳繃struts-config.xml灝嗗涓猘ction-mapping鏄犲皠鍒板悓涓涓狝ction綾葷殑涓嶅悓鏂規硶涓? 鍏稿瀷鐨勯厤緗氨鏄?
鐒跺悗UserAction緇ф壙MappingDispatchAction錛屽叾涓湁錛?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>
鍙互鐪嬪埌, 涓嶇鎬庝箞鍙樺寲, 鍏跺疄榪欎簺綾婚兘鏄妸execute緇欏垎瑙e紑, 涓嶇鏄痵ave, edit榪樻槸鍏朵粬浠涔堟柟娉? 鍏跺疄閮芥槸鍜屽師鏉ョ殑execute鏄瓑浠風殑, save鍜宔dit涔嬮棿娌℃湁浠諱綍鐩存帴鐨勫叧緋? 鑰屼簨瀹炲憿錛屽畠浠槸鍚屼竴涓笟鍔℃ā鍨嬬殑涓ょ涓嶅悓鎿嶄綔銆?鎴戣寰楄繖灝辨槸涓涓棶棰橈紝瀵逛簬save鍜宔dit榪欎袱縐嶈姹? 鎴戝悗鍙伴昏緫鏈夊彲鑳藉彧鏄皟鐢╯ervice鐨勬柟娉曢偅涓鍙ヤ笉涓鏍鳳紝鍏朵粬浠g爜鏄畬鍏ㄤ竴鑷寸殑(渚嬪閿欒澶勭悊, 鏃ュ織璁板綍絳?銆傚洜姝ゆ垜鎯沖嚭浜嗚繖涓皬涓滆タ錛屽湪execute鏂規硶鍐呴儴榪涜灞閮ㄥ垎瑙?/p>
涓鑸潵璇達紝涓涓畬鏁寸殑鎶ヨ〃璁捐嫻佺▼錛屽ぇ浣撳垎涓哄涓嬪嚑涓楠わ細
鎵撳紑璁捐鍣?/span>à閰嶇疆鏁版嵁婧?/span>à鏂板緩鎶ヨ〃à瀹氫箟縐佹湁鏁版嵁婧?/span>à鎶ヨ〃璁捐à棰勬徑鎶ヨ〃à鍙戝竷鎶ヨ〃
鍏蜂綋鐨勬楠ゆ垜灝變笉澶氳浜?璇ヨ蔣浠舵湁寰堣緇嗙殑甯姪璇存槑鏂囨。.鍙弬鑰冨畠鐨勮鏄庢枃妗?濡傛湁涓嶆竻妤氱殑鍦版柟.鍙互鐣欒█鎴栦簬鎴戣仈緋?..鎴戣繖閲屾湁鍋氬ソ鐨勫疄渚?鍙緵澶у鍙傝?.
4.鍦╳eb-inf鐩綍涓嬪緩绔嬩竴涓猽rlrewrite.xml.鍦ㄨ鏂囦歡閲屾坊鍔犱互涓嬩唬鐮?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:鏄垜鑷繁鏂板緩鐨凧SP鏂囦歡. id:鏄弬鏁板悕,鍙傛暟鍚嶅彲浠ラ殢渚垮畾涔? id=$1鏄搴旂殑鏍煎紡鍖栬〃杈懼紡
</rule>
</urlrewrite>
5.鐒跺悗鍦╳ebroot涓嬮潰寤虹珛1涓猧ndex.jsp鍦╦sp閲屽姞鍏?br />
<% System.out.println(request.getParameter("id")); %>
鐪嬬湅id鎵撳嚭鏉ユ槸涓粈涔堝唴瀹?
6.鍦ㄥ惎鍔╰omcat鏈嶅姟鍣?鍦╥E涓婅緭鍏ttp://localhost:8080/宸ョ▼鍚?tmac/a.html/灝卞彲浠ョ湅鍒版晥鏋?鍦ㄨ繖閲?./tmac/a.html鏄牴鎹畊rlrewrite.xml閲岄潰from鏍囩鐨勫兼潵鐨?涓瀹氳鍜宖rom鏍囩鐨勫煎尮閰?/p>