1.配置web.xml文件
<web-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID"version="2.5"><!--設置轉發--><servlet><servlet-name>DispatcherServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><!--加載配置文件--><param-value>classpath:applicationContext.xml</param-value></init-param><!--標記容器是否在啟動的時候就加載這個servlet。當值為0或者大于0時,表示容器在應用啟動時就加載這個servlet;當是一個負數時或者沒有指定時,則指示容器在該servlet被選擇時才加載。正數的值越小,啟動該servlet的優先級越高。--><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>DispatcherServlet</servlet-name><!--接受所有請求--><url-pattern>/</url-pattern></servlet-mapping></web-app>
2.配置applicationContext.xml文件
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsd"><!--這里可以去掉,因為下面自動掃描包的代碼,就包含了該行的功能--><context:annotation-config/><!--自動掃描web包,將帶有注解的類納入spring容器管理--><context:component-scanbase-package="com.zds"></context:component-scan></beans>
3.新建Controller文件
packagecom.zds;/***@authorzds*@date2018年3月6日*/importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annotation.RequestMethod;importorg.springframework.web.bind.annotation.RequestParam;importorg.springframework.web.bind.annotation.ResponseBody;importorg.springframework.web.bind.annotation.RestController;@RestController@RequestMapping("/test")publicclassTestController{@RequestMapping(value="hello",method=RequestMethod.GET)@ResponseBodypublicStringhelloWorld(@RequestParam("user")StringuserName){Stringstring="";string.split(",");return"Hello"+userName+"!";}}
讀到這里,這篇“java Spring框架如何搭建”文章已經介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領會,如果想了解更多相關內容的文章,歡迎關注本站行業資訊頻道。
本文由 貴州做網站公司 整理發布,部分圖文來源于互聯網,如有侵權,請聯系我們刪除,謝謝!
c語言中正確的字符常量是用一對單引號將一個字符括起表示合法的字符常量。例如‘a’。數值包括整型、浮點型。整型可用十進制,八進制,十六進制。八進制前面要加0,后面...
2022年天津專場考試原定于3月19日舉行,受疫情影響確定延期,但目前延期后的考試時間推遲。 符合報名條件的考生,須在規定時間登錄招考資訊網(www.zha...
:喜歡聽,樂意看。指很受歡迎?!巴卣官Y料”喜聞樂見:[ xǐ wén lè jiàn ]詳細解釋1. 【解釋】:喜歡聽,樂意看。指很受歡迎。2. 【示例】:這是...
【資料圖】有關巡回檢察組米振東的真實身份方面的知識,估計很多人不是太了解,今天就給大家詳細的介紹一下關于巡回檢察組米振東的真實身份的相關內容。1、米振東的真實身份是:隱藏在幕后的大BOSS,米振東與馮森的關系是“弒母殺妻死敵”,而米振東與徐大發的關系是“謀殺,嫁禍”。僅憑這兩條,就足以證明了米振東是反派角色。2、《巡回檢察組》是由最高人民檢察院影視中心、中共山東省委宣傳部、金盾影視中心和湖南廣播電...
mlf俗稱“麻辣粉”,即中期借貸便利,是我國央行采取的一種創新型貨幣政策工具,也是央行提供中期基礎貨幣的貨幣政策工具,對象為符合宏觀審慎管理要求的商業銀行、政策性銀行。理解mlf的概念,還要從以下幾個方面入手。1、增加貨幣供應量。mlf是央行向社會注入流動性的一種方式,通過向市場提供中期基礎性貨幣,增加貨幣供應量,在一定程度上可以緩解小微企業、三農等需要扶持行業融資難的問題...
1、蘋果手機稱重功能使用教程2、打開手機設置,找到觸控選項。(資料圖片)3、 4、在touch中開啟三維觸摸和觸覺觸摸功能。5、 6、打開后進入瀏覽器搜索touchscale(點擊英文單詞直接進入)。7、 8、進入如下屏幕電子秤頁面。9、 10、這時候把物體放在手機上就可以稱重了。11、 12、注:由于該功能要求手機具備3dtouch功能,目前支持該功能的蘋果手機型號有:iPhone 6s、iPh...