基于CXF

时间:2017-02-13 16:28:10

标签: spring rest spring-mvc cxf query-parameters

在Spring MVC中,对于RESTful服务,如果URI和HTTP方法对于两个或更多不同的资源是相同的,那么可以使用 NOT(!)运算符基于查询参数使它们互斥使用Query Param,例如:

@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中实现这一目标?

1 个答案:

答案 0 :(得分:0)

CXF和Spring MVC无法直接比较。 CXF是RESTful服务的Java Api实现JAX-RS

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

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


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