2
有什麼辦法可以配置Spring-MVC嚴格接受已知的查詢字符串列表嗎?我期待,以驗證提交的查詢字符串 - 如果請求額外的查詢字符串參數,我想了解它,並返回一個404Spring MVC能嚴格映射查詢字符串來請求參數嗎?
我的動機是:
- 清晰:我不希望客戶端發送請求參數,並仍然返回結果(就像沒有提供請求參數一樣)
- HTTP緩存:我想限制用於我的服務的有效HTTP路由的數量以便HTTP緩存(即清漆)將更好地工作
例如,我可能是配置爲採取一個簡單的控制器,一個RequestParam
:
@RequestMapping(value = "/selective_route", method = RequestMethod.GET)
public String printTest(@RequestParam String test) {
return test;
}
現在我想我的應用程序接受請求並返回一個OK響應:
/selective_route?test=foo
但我希望我的應用程序注意到還有其他未下載的請求參數,並返回ERROR響應代碼。
/selective_route?test=foo&someotherparam=somethingelse
似乎是一個重複http://stackoverflow.com/questions/10010176/spring-mvc-how-to-check-that-no-unexpected-query-string-parameters-has-been-pa –