2011-09-19 35 views
2

我通常會檢索POST參數如下所示:當Spring中的某些URL在URL中時,POST參數如何處理?

@RequestMapping(method = RequestMethod.POST) 
public ModelAndView create(
    @RequestParam(value = "first_name", required = false) String firstName, 
    HttpServletRequest request 
) { 

但是,如果一些參數是一樣http://example.com/post/path?last_name=Smith的網址是什麼?當RequestMapping是POST時,Spring是否應該從URL和POST數據中獲取所有參數?

基本上,Facebook通過POST和其他參數(如request_ids)通過URL參數同時發送signed_request參數。我需要得到兩個。

回答

4

但是,如果一些參數是一樣 http://example.com/post/path?last_name=Smith的網址是什麼? RequestMapping是POST嗎?是否應該從 獲取來自URL和POST數據的所有參數?

是的,spring會爲POST請求獲取所有參數值(在表單和url中)。但在你的情況下

@RequestParam(value = "first_name", required = false) String firstName, 

將爲空。因爲在你的網址中,參數名稱是last_name。 :D

+0

嗯......我的問題的重點是,如果Spring從POST和URL中獲取參數。 'first_name'在POST中,'last_name'在URL中。 –

+0

是的,spring會從Form:input和url中獲取參數。 – Kent

0

我不知道這個回答你的問題的有效方式,但是,Linux的發言:

  1. POST參數出現在服務器標準輸入;

  2. GET參數(URL中的參數)出現在QUERY_STRING中。

HTH

+0

嗯......謝謝你? –