2017-04-05 83 views
0

我有類似下面的AA請求映射:Spring MVC的RequestParam可選值

@RequestMapping(value = "/init/filter/", method = RequestMethod.POST) 
    @ResponseBody 
    public final Reponse filterGrid(
      @RequestParam(value = "nom", required = false) final String nom, 
      @RequestParam(value = "matricule", required = false) final String matricule, 
      final HttpServletRequest httpRequete, 
      final HttpServletResponse httpReponse, Model model) { 
} 

而且在我的javascript,我這個網址:

POST http://localhost:8080/project/pages/rest/consultation/bulletinhorscontrat/init/filter/nom=test 404 (Introuvable)

我得到了一個未找到頁面

我試過用GET和我得到了相同的錯誤

我在Spring MVC方法中忘了什麼?

感謝的

+0

您能否提供帶有錯誤描述的任何日誌? –

+0

在我的日誌文件中我沒有錯誤,我在瀏覽器中只有這個: Erreur網頁編號:404 Navigateur:Mozilla 地址:../../pages/rest/consultation/bulletinhorscontrat/init/filter/nom = COTREZ 描述: 行政法院HTTP 404 - 型融洽D''政變 消息 描述的La的ressourcedemandéen''est PAS disponible。 的Apache Tomcat/7.0.59 – Pasja95

+0

要檢查錯誤的詳細信息,設置日誌春級別進行調試 –

回答

0

用POST方法不能傳遞變量的鏈接,你應該使用@RequestBody代替。

但在你的情況Get方法應該做的工作,但即便如此,你需要更改鏈接的格式,這裏的新鏈接:

http://localhost:8080/project/pages/rest/consultation/bulletinhorscontrat/init/filter?nom=t&matricule=mat 

從鏈接中刪除最後一個/因爲它是沒有意義的,並將POST更改爲獲取:

@RequestMapping(value = "/init/filter", method = RequestMethod.GET) 
    public final Reponse filterGrid(
      @RequestParam(value = "nom", required = false) final String nom, 
      @RequestParam(value = "matricule", required = false) final String matricule, 
      final HttpServletRequest httpRequete, 
      final HttpServletResponse httpReponse, Model model) { 
} 
+0

我得到了更新我的代碼後 – Pasja95

+0

你能提供你的類頭以驗證您正在使用 – bougsid

+0

@RequestMapping(「鏈接相同的錯誤/休息/諮詢/ bulletinhorscontrat「) 公共類Controleur延長ControleurRacine。 我在控制器的其他方法,我可以訪問他們,錯誤不是在控制器鏈接 – Pasja95

相關問題