锘??xml version="1.0" encoding="utf-8" standalone="yes"?>伊人春色之综合网,1024国产在线,成年人视频在线免费观看http://www.aygfsteel.com/flio/articles/379589.htmlflioflioWed, 30 May 2012 12:33:00 GMThttp://www.aygfsteel.com/flio/articles/379589.htmlhttp://www.aygfsteel.com/flio/comments/379589.htmlhttp://www.aygfsteel.com/flio/articles/379589.html#Feedback0http://www.aygfsteel.com/flio/comments/commentRss/379589.htmlhttp://www.aygfsteel.com/flio/services/trackbacks/379589.html涓婄瘒璁插埌浜唖pringmvc瀹炵幇浜嗘帶鍒跺眰鐨刪elloworld瀹炰緥錛岃繖綃囨帴鐫鍐檚ervice灞傦紝鍜宒ao灞傜殑鏁村悎銆?br />榪欓噷浼?xì)闇瑕佸嚑涓厤緗枃浠訛紝applicationContext.xml錛宼est-service.xml,test-dao.xml
applicationContext涓昏灝辨槸鍖呭惈鍚庨潰涓や釜鏂囦歡浜嗐傚叾瀹炶繖涓変釜鏂囦歡鍙互鍐欏湪涓涓厤緗枃浠朵腑錛屼笉榪囦負(fù)浜嗘洿濂界殑鍒嗙錛屾墍浠ユ媶寮浜哾ao鐨勯厤緗枃浠訛紝鍜宻ervice鐨勯厤緗枃浠躲?br />applicationContext.xml浠g爜涓昏濡備笅:

<?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:context
="http://www.springframework.org/schema/context"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    ">
    <!-- 鏁版嵁璁塊棶灞傞厤緗?nbsp;-->
    
<import resource="classpath:/configSource/test-dao.xml" />
     
<!--鏈嶅姟灞傞厤緗?nbsp;-->
    
<import resource="classpath:/configSource/test-service.xml" />
</beans>
  

test-dao.xml浠g爜涓昏濡備笅

<?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:tx="http://www.springframework.org/schema/tx"
    xmlns:context
="http://www.springframework.org/schema/context"
    xmlns:p
="http://www.springframework.org/schema/p"
    xsi:schemaLocation
="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    <!-- 鎵弿com.baobaotao.dao鍖呬笅鎵鏈夋爣娉ˊRepository鐨凞AO緇勪歡 -->
    
<context:component-scan base-package="com.Integrat.*.dao"/>
    
</beans>

test-service.xml鐨勯厤緗唴瀹瑰涓嬶細(xì)

<?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:tx="http://www.springframework.org/schema/tx"
    xmlns:aop
="http://www.springframework.org/schema/aop"
    xmlns:context
="http://www.springframework.org/schema/context"
    xmlns:p
="http://www.springframework.org/schema/p"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
   <!-- 鎵弿com.baobaotao.service鍖呬笅鎵鏈夋爣娉ˊService鐨勬湇鍔$粍浠?nbsp;-->
    
<context:component-scan base-package="com.Integrat.*.service"/>
    
</beans>

test-dao.xml,test-service.xml 閮芥槸緇忚繃浜嗙畝鍗曠殑閰嶇疆錛屽茍涓嶆槸瀹屾暣鐨勶紝璇鋒敞鎰忥紝鍙槸婕旂ず涓涓厤緗殑榪囩▼錛屼竴姝ユ鐨勯厤緗紝璁頒笅姣忎竴姝ョ殑浣滅敤錛屼簡瑙d笅鍘熺悊銆?br />鍙互鐪嬪埌涓婇潰涓や釜閰嶇疆鏂囦歡姣忎釜閲岄潰閮藉彧鏈?琛岃鍙ワ紝灝辨槸鑷姩鎵弿娉ㄨВ鐨剆ervice鍜宒ao錛屽鏋滆繖閲屼笉閰嶇疆鐨勮瘽錛屽湪service鍜宒ao綾諱笂娉ㄨВ浜嗕篃娌℃硶瑙f瀽錛屽彲鑳界垎鍑篵ean鍒涘緩閿欒
娉ㄦ剰璧嬪肩殑鏃跺欙紝闇瑕佹敼涓嬬洰褰曠粨鏋勶紙com.Integrat.*.service 榪欓噷鏀規(guī)垚鑷繁鐨剆ervice璺緞*琛ㄧず閫氶厤絎︼級
閰嶇疆濂戒簡灝卞紑濮嬪啓浠g爜鍚э紝棣栧厛鍐檇ao灞傚惂浠g爜濡備笅錛?br />
@Repository
public class DemoDao extends BaseDao<AdminDicVO>{
    
public void demo(){
        System.out.println(
"demoDAO鎵ц浜?img src="http://www.aygfsteel.com/Images/dot.gif" alt="" />");
    }

    
}

濡傛灉璋冪敤浜哾ao灞備細(xì)綆鍗曞湪鎺у埗鍙拌緭鍑轟竴孌佃瘽錛屽煎緱娉ㄦ剰鐨勬槸鍦ㄧ被鍚嶄笂闈㈣鍐欎笂娉ㄨВ@Repository 錛岃〃紺鴻繖鏄痙ao灞?br />鎺ョ潃鍐檚ervice灞備唬鐮佸涓嬶細(xì)

@Service
public class DemoService{
    @Autowired
    
private DemoDao dao;
    
public void Test(){
        System.out.println(
"service璋冪敤dao灞?img src="http://www.aygfsteel.com/Images/dot.gif" alt="" />");
        dao.demo();
    }

}

榪欓噷闇瑕佹敞鎰忕殑鏄湪綾誨悕涓婇潰闇瑕佸啓涓夽service娉ㄨВ錛岃〃紺鴻繖鏄竴涓猻ervice錛屽湪private DemoDao dao; 涓婇潰瑕佸啓涓婃敞瑙Autowired錛岃嚜鍔ㄦ敞鍏ヨ繖涓猟ao錛?br />鎺ヤ笅鏉ュ氨鐪媍ontroller灞備唬鐮佷簡:

@Controller
@RequestMapping(
"/demo")
public class DemoController {
    @Autowired 
    
private DemoService service;  //榪欓噷娉ㄥ叆service
    @RequestMapping("/demo1")
    
public String demo(){
        System.out.println(
"controller鎵цdemo,璋冪敤service");
        service.Test();
        
return null;
    }

    
}

灝辮繖涔堢畝鍗曠殑浠g爜灝卞彲浠ラ氳繃controller璋冪敤service錛岄氳繃service璋冪敤dao灞備簡
鎺ヤ笅鏉ュ氨璁塊棶涓?a href="http://localhost:8080/">http://localhost:8080/欏圭洰鍚?demo/demo1.test  灝卞彲浠ョ湅鍒版帶鍒跺彴鎵撳嵃鍑虹殑鏁版嵁浜嗐?br />榪欐牱mvc3灞傚氨緇撳悎璧鋒潵浜嗐傚線鍚庯紝鍙渶瑕佸湪鍦╠ao灞傚姞鍏ibernate錛屽皝瑁卋asedao錛屽湪service灞傞厤緗簨鍔★紝灝眔k浜嗐?br />鏁村悎hibernate寰呯畫...


flio 2012-05-30 20:33 鍙戣〃璇勮
]]>
SpringMVC+hibernate3(1.璁﹕pringmvc璺戣搗鏉ワ級http://www.aygfsteel.com/flio/articles/379540.htmlflioflioWed, 30 May 2012 05:38:00 GMThttp://www.aygfsteel.com/flio/articles/379540.htmlhttp://www.aygfsteel.com/flio/comments/379540.htmlhttp://www.aygfsteel.com/flio/articles/379540.html#Feedback0http://www.aygfsteel.com/flio/comments/commentRss/379540.htmlhttp://www.aygfsteel.com/flio/services/trackbacks/379540.html榪欐鏃墮棿寮濮嬪皝瑁呭叕鍙稿唴閮ㄤ嬌鐢ㄧ殑寮鍙戞鏋訛紝鍩轟簬鎬ц兘鐨勮冭檻錛屼嬌鐢╯rpingmvc+hibernate鎶鏈紝涓嬮潰鏄竴浜涙惌寤鴻繃紼嬶紙涓嶅寘鍚玠ao灞傚皝瑁咃級錛屽啓涓嬫潵澶囧繕銆?br />1.璁﹕pringmvc璺戣搗鏉?br />榪欎釜榪囩▼寰堢畝鍗曘傚鍏pring鐨刯ar鍖呭氨濂戒簡錛岃繖閲岀畝鍗曠殑浠嬬粛涓媕ar鍖呭惂銆備富瑕佸垎srping鐨勫疄鐜板寘錛屽拰渚濊禆鍖?br />涓誨寘錛歴pring-framework-3.1.1.RELEASE-with-docs.zip
渚濊禆錛歴pring-framework-3.0.1.RELEASE-A-dependencies.zip
涓誨寘涓笉闇瑕佸叏閮ㄥ姞榪涘幓錛岄変竴浜涢渶瑕佺殑灝卞ソ浜嗗涓?



鐒跺悗鍐嶅姞鍏ヤ緷璧栵細(xì)


鍔犲叆浜唈ar鍖呭悗灝卞紑濮嬮厤緗畐eb.xml鏂囦歡錛屽湪web.xml涓姞鍏ュ涓嬩唬鐮併?br />
<!--鍒濆鍖杝rpingMVC-->
  
<servlet>
   
<servlet-name>test</servlet-name>
   
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   
<!-- 榪欐牱鍙互閰嶇疆xml-servlet錛屼笉榛樿鎵総est-servlet.xml -->
   
<init-param>
    
<param-name>contextConfigLocation</param-name>
    
<param-value>classpath:/configSource/test-servlet.xml</param-value>
   
</init-param>
   
<load-on-startup>1</load-on-startup>
</servlet>
  
<servlet-mapping>
   
<servlet-name>test</servlet-name>
   
<!--榪欓噷鎴戞槸鎷︽埅浠?test緇撳熬鐨勮姹?/span>-->
   
<url-pattern>*.test</url-pattern>
  
</servlet-mapping>

鍥犱負(fù)srpingmvc鏄熀浜巗ervlet瀹炵幇鐨勩傛墍鏈夎姹傞兘闇瑕侀氳繃DispatcherServlet鏉ヨ漿鍙戣姹?br />瑙i噴涓媔nit-param榪欐錛岄粯璁ゅ彲浠ヤ笉闇瑕侀厤緗殑錛屽彧瑕佸湪WEB-INF涓嬮潰瀹氫箟test-servlet.xml灝卞彲浠ヨ嚜宸辨壘鍒扮殑錛岋紙test-servlet.xml錛岃繖涓悕瀛楃殑鐢辨潵鏄洜涓烘垜鐨剆ervlet鐨刵ame鏄痶est錛屾墍鏈夋湁test-servlet.xml鏂囦歡灝變細(xì)鑷姩鎵懼埌榪欎釜鏂囦歡錛岀孩鑹插瓧浣撴爣娉級錛岃繖鏍風(fēng)殑璇濅笅闈㈢殑init-param榪欎竴涓妭鐐瑰氨鍙互涓嶉渶瑕侀厤緗簡銆?br />浣嗘槸涓轟簡綆$悊鏂逛究錛屾垜鏀懼湪浜?span style="color: #339966">configSource榪欎釜鍖呴噷闈紝鎵浠ユ垜鍦╬aram-value涓殑<param-value>classpath:/configSource/*-servlet.xml</param-value>鏄繖鏍烽厤緗殑銆傚熀鏈繖鏍峰氨閰嶇疆瀹屼簡錛屽彲浠ョ畝鍗曟祴璇曪紝灝辨潵涓猦elloworld渚嬪瓙鍚с?br />鍦╰est-servlet.xml涓厤緗涓嬩唬鐮侊細(xì)
 1<beans xmlns="http://www.springframework.org/schema/beans"
 2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
 3 xmlns:context="http://www.springframework.org/schema/context"
 4 xmlns:mvc="http://www.springframework.org/schema/mvc"
 5 xsi:schemaLocation="http://www.springframework.org/schema/beans   
 6           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
 7           http://www.springframework.org/schema/mvc  
 8           http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
 9           http://www.springframework.org/schema/context   
10           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
11 <!-- 鑷姩鎵弿com.baobaotao.web 鍖呬笅鐨凘Controller鏍囨敞鐨勭被鎺у埗鍣ㄧ被 -->
12 <context:component-scan base-package="com.Integrat.*.controller" />
13 <!-- 鍚姩Spring MVC鐨勬敞瑙e姛鑳斤紝瀹屾垚璇鋒眰鍜屾敞瑙OJO鐨勬槧灝?nbsp;-->
14 <mvc:annotation-driven/>
15</beans>
16

閲嶇偣鍙湁涓ゅ彞錛屽氨鏄紑鍚敞瑙o紝鍜岃嚜鍔ㄦ壂鎻忔帶鍒跺櫒
base-package="com.Integrat.*.controller"  榪欎釜搴旇鎳備簨榪欎箞鎰忔濅簡鍚э紝涓嶈В閲娿?br />閰嶇疆濂借繖浜涗簡灝卞紑濮嬪啓controller鍚?br />浠g爜濡備笅錛?br />

 

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;

@org.springframework.stereotype.Controller   
//榪欓噷鏄敞瑙o紝琛ㄧず榪欐槸涓涓帶鍒跺櫒
@RequestMapping("/helloworld")                    //榪欓噷鏄闂礬寰勶紝涓漢鎰熻鍜宻truts鐨刵amespace涓鐐圭被浼鹼紝涓嶈繃鍔熻兘涓嶆濡傛錛岀暐榪?/span>
public class HelloWorldController{
     @RequestMapping(
"/hello")                      //娉ㄦ剰榪欓噷涔熷啓涓?/span>
     public String query(){
              System.out.println(
"hello world錛侊紒錛?/span>");
              
return null;
     }

}



榪欐牱鍩烘湰灝卞彲浠ヤ簡銆傚彂甯冮」鐩紝璁塊棶鍦板潃-->  http://localhost:8080/欏圭洰鍚?helloworld/hello.test
灝卞彲浠ョ湅鍒版帶鍒跺彴杈撳嚭helloworld浜嗐?br />鏈畬寰呯畫....



flio 2012-05-30 13:38 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 武定县| 德化县| 洪江市| 安平县| 安新县| 武山县| 上饶市| 柳河县| 河间市| 鹰潭市| 罗平县| 黄陵县| 隆化县| 石家庄市| 濉溪县| 东至县| 团风县| 莒南县| 汕头市| 新巴尔虎右旗| 名山县| 浦东新区| 彩票| 中卫市| 内江市| 滁州市| 大荔县| 扶沟县| 辽宁省| 和硕县| 西平县| 安塞县| 海兴县| 沈丘县| 皋兰县| 屯门区| 滦南县| 四平市| 东阳市| 宿迁市| 竹山县|