SpringMVC - @RequestMapping 映射請求

來源:互聯網
上載者:User

標籤:使用   return   isp   blog   dispatch   ppi   標記   post   hello   

@RequestMapping 映射請求
1.SpringMVC使用@RequestMapping註解為控制器指定可以處理哪些URL請求。
2.在控制器的類定義及方法定義處都可標註@RequestMapping。
(1).類定義處:提供初步的請求映射資訊。相對於WEB應用的根目錄。
(2).提供進一步的細分映射資訊。相對於類定義處的 URL。
若類定義處未標註@RequestMapping,
則方法處標記的 URL 相對於WEB 應用的根目錄。
3.DispatcherServlet截獲請求後,就通過控制器上@RequestMapping
提供的映射資訊確定請求所對應的處理方法。

@Controller@RequestMapping("/hello")public class HelloController {    @RequestMapping("/helloWorld")    public String helloWord(){        System.out.println("Hello World!");        return "success";    }}

 


程式碼範例:

SpringMVC - @RequestMapping 映射請求

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.