- Mastering Microservices with Java 9(Second Edition)
- Sourabh Sharma
- 169字
- 2021-07-02 21:54:45
The @RequestMapping annotation
The @RequestMapping annotation is used at class level to map the /calculation URI to the CalculationController class, that is, it ensures that the HTTP request to /calculation is mapped to the CalculationController class. Based on the path defined using the annotation @RequestMapping of the URI (postfix of /calculation, for example, /calculation/sqrt/144), it would be mapped to respective methods. Here, the request mapping /calculation/sqrt is mapped to the sqrt() method and /calculation/power is mapped to the pow() method.
You might have also observed that we have not defined what request method (GET/POST/PUT, and so on) these methods would use. The @RequestMapping annotation maps all the HTTP request methods by default. You could use specific methods by using the method property of RequestMapping. For example, you could write a @RequestMethod annotation in the following way to use the POST method:
@RequestMapping(value = "/power", method = POST)
For passing the parameters along the way, the sample demonstrates both request parameters and path parameters using annotations @RequestParam and @PathVariable, respectively.
- HornetQ Messaging Developer’s Guide
- Visual C++程序設(shè)計(jì)學(xué)習(xí)筆記
- Interactive Data Visualization with Python
- Hands-On Data Structures and Algorithms with JavaScript
- Java虛擬機(jī)字節(jié)碼:從入門到實(shí)戰(zhàn)
- Python數(shù)據(jù)分析(第2版)
- Data Analysis with Stata
- Unity Game Development Scripting
- C#實(shí)踐教程(第2版)
- Raspberry Pi Robotic Projects(Third Edition)
- Python Machine Learning Blueprints:Intuitive data projects you can relate to
- Practical Maya Programming with Python
- SCRATCH編程課:我的游戲我做主
- Effective C++:改善程序與設(shè)計(jì)的55個(gè)具體做法(第三版)中文版(雙色)
- Mastering Machine Learning with scikit-learn