- Cloud-Native Applications in Java
- Ajay Mahajan Munish Kumar Gupta Shyam Sundar
- 119字
- 2021-06-24 19:07:16
Testing the service on the browser
Open a browser and hit the following URL: http://localhost:8080/product/1.
You should get back the following response:
{"id":1,"name":"Oranges ","catId":2}
Now, try the other service (URL—http://localhost:8080/productIds). What response do you get? An error, as follows:
There was an unexpected error (type=Bad Request, status=400). Required int parameter 'id' is not present
Can you guess why? It is because the service definition that you wrote had a method expecting a request parameter:
@RequestMapping("/productIds")
List<Integer> getProductIds(@RequestParam("id") int id) {
So, the URL is expecting an id and as you did not supply it, it gives an error.
Give the parameter and try http://localhost:8080/productIds?id=5 again.
You will now get back a correct response:
[6,7,8]
推薦閱讀
- 電力通信實(shí)用技術(shù)問答
- Protel DXP 2004 SP2原理圖與PCB設(shè)計(jì)
- 通信原理
- 天空地一體化自組織網(wǎng)絡(luò)導(dǎo)航技術(shù)及應(yīng)用
- 5G承載網(wǎng)絡(luò)運(yùn)維(初級(jí))
- 一個(gè)APP的誕生2.0:從零開始設(shè)計(jì)你的手機(jī)應(yīng)用
- LED照明電路設(shè)計(jì)100例
- 妙用微信微博就讀它
- 動(dòng)手指,知天下:老年人學(xué)用智能手機(jī)
- 認(rèn)識(shí)5G+
- 電子電路知識(shí)與實(shí)踐課堂
- Android移動(dòng)應(yīng)用開發(fā)技術(shù)與實(shí)踐
- 物聯(lián)產(chǎn)品電磁兼容分析與設(shè)計(jì)
- 電磁兼容設(shè)計(jì)與整改對策及案例分析
- 傳輸網(wǎng)工程維護(hù)手冊