Spring请求映射具有不同的参数和一个相同的参数

时间:2016-07-12 11:08:03

标签: java spring spring-mvc request

我有弹簧代码,请求如下:

@RequestMapping(method = RequestMethod.GET, value = {
        EnterpriseLiterals.ROOT_URL_SIMPLE + "storeDepartments/search.json",
        EnterpriseLiterals.ROOT_URL_SIMPLE + "storeDepartments/search" },params = { "!dealerStoreId" })
public Map<String, List<? extends AbstractDepartment>> getDepartments(
            @RequestParam(value = "enterpriseId", required = true) String enterpriseId,@RequestParam(value = "responseFields", required = false) String responseFields)

另一个请求为:

@RequestMapping(method = RequestMethod.GET, value = {
        EnterpriseLiterals.ROOT_URL_SIMPLE + "storeDepartments/search",
        EnterpriseLiterals.ROOT_URL_SIMPLE + "storeDepartments/search.json" },params = {"!enterpriseId"})
@ResponseBody
public Map<String, List<AbstractDepartment>> getDepartmentListBasedOnStoreAndDeptType(@RequestParam(value = "dealerStoreId", required = true) String dealerStoreId,@RequestParam(value = "responseFields", required = false, defaultValue = "summary") String responseFields)

但是,由于我在两个请求中都有responseFields,当我使用responseFields调用上述API并且“ResponseFields不存在”时,我收到错误。 请帮助解决这个问题的解决方案。

0 个答案:

没有答案