RESTful CXF中基于查询参数的URI资源互斥

RESTful URI Resource mutual exclusion based on query param in CXF

在Spring MVC中,对于RESTful服务,如果两个或多个不同资源的URI和HTTP方法相同,则可以使用[=根据查询参数使它们互斥16=]NOT(!) 带有查询参数的运算符,例如:

@RequestMapping(method = RequestMethod.POST, value = "/authentication", params = { "password", "!ssn" })
    @ResponseBody
    public SessionResponse userLogin(@Valid @ModelAttribute final UsernameAuthFormBean usernameAuthFormBean,
            final BindingResult bindingResult, final HttpServletRequest request, final HttpServletResponse response) {}



@RequestMapping(method = RequestMethod.POST, value = "/authentication", params = { "!password", "ssn" })
    @ResponseBody
    public SessionResponse forgotPassword(@Valid @ModelAttribute final ForgotPasswordFormBean forgotPasswordFormBean,
            final BindingResult bindingResult, final HttpServletRequest request, final HttpServletResponse response) {}

如何在 CXF 中实现?

CXF 和 Spring MVC 不能直接比较。 CXF 是 Java Api 的 RESTful 服务 JAX-RS

的实现

此运算符 ! 未出现在规范中,CXF 未实现它。您需要使用不同的 URI

@POST
@Path("/authentication/userLogin")
public Response userLogin(@FormParam("") UsernameBean bean)


@POST
@Path("/authentication/forgotPassword")
public Response forgotPassword(@FormParam("") ForgotPasswordBean bean)