Spring3 0實現REST例項

2021-05-26 06:52:22 字數 603 閱讀 2800

關於rest是什麼東西,在這裡我就不再多說,大家可以去看看介紹,直接切入主題:

這是乙個rest風格的訪問,spring從3.0開始將全面支援rest。不得不感嘆spring的強悍。

專案結構:

第一步永遠是配置,使用框架永遠都是先有配置,在web.xml中的配置:

第三步:具體實現類

index.jsp頁面:

在瀏覽器中輸入:http://localhost:8080/springrest/******/index/,就可以看到效果。

關於spring rest 對於ajax的支援,其實響應ajax就是通過response返回乙個字串到頁面,既然能獲得response物件,那問題就迎刃而解了,我們改造下get方法:

改造index.jsp頁面:

訪問http://localhost:8080/springrest/******/index/,在頁面裡的輸入框中輸入值,可以看到返回的資料:

Spring3 0將全面支援REST

rod johnson上個月底說,spring 3.0全面支援rest風格的web服務。we re really seeing extensive interest and growth in rest,and it will h e comprehensive support for restfu...

spring3 0學習之環境搭建

最近搞定了專案,工作終於松了下來,回頭整理一下spring學習的資料,記錄於此,不足之處,希望大家不吝賜教。關於這一塊的討論,希望大家關注qq討論群 spring原始碼研究群 64606455,綜合技術討論群 178547149 contextconfiglocation web inf sprin...

spring3 0設定定時任務

今天做個小需求,需要用到定時器。就把以前寫過的配置檔案模板直接複製過來,又順手點進去看了一下原始碼,發現time ctorybean scheduledtimertask都已經被標記成 deprecated了 deprecated public class time ctorybean implem...