2017-02-13 58 views
0

在Spring MVC中,对于RESTful服务,如果URI和HTTP方法对于两个或更多不同资源是相同的,则可以使用基于查询参数使它们互斥(!)NOT运营商查询帕拉姆如:基于CXF中查询参数的RESTful URI资源互斥

@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中实现?

回答

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) 
+0

其实我们有一个现有的应用程序,我们有谁正在使用我们现有的端点,我不能改变的URI的多个客户端,但我们必须迁移距离Spring MVC到CXF这个应用程序,所以是有什么解决办法吗? – Narendra

+0

然后你需要自己实现操作的逻辑:1)为uri'/authentication'定义一个唯一的方法2)解析查询参数并选择目标方法3)解析表单参数和调用目标方法 – pedrofb