2016-06-08 20 views

回答

0

我不是Spring MVC大師,但它看起來像@RequestParam可讓您訪問查詢參數或請求正文中的參數。

所以http://example.com?name=Enosh你需要一個@RequestParam("name")作爲參數傳遞給你的方法。

假設是否正確......

你典型的快遞航線聲明如下:

app.get('users/:id', function iAmExecutedWhenTheUserCallsThisEndpoint(req, res, next) { 

}) 

而且用戶調用此與http://example.com/users/42?expanded=true

要獲得:id部分,使用req.params.id < - 注意這與:id匹配。查看Express documentation on req.params

獲取expanded部分req.query.expanded。請參閱Express documentation on req.query。所以:回答你的問題:所有的東西都離開傳入你的函數的請求對象,而你的函數只能用三個參數調用:req,resnext,以上。

相關問題