针对不同端点的CXF拦截器配置

问题描述 投票:0回答:1

当前的CXF配置:

<jaxrs:server id="rest" address="/path">
    <jaxrs:serviceBeans>
        <ref bean="myService" />
    </jaxrs:serviceBeans>
    <jaxrs:providers>
        <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
    </jaxrs:providers>
    <jaxrs:inInterceptors>
        <ref bean="restLogInterceptor" />
    </jaxrs:inInterceptors>

和春天休息:

@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
@Path("path")
public interface Service {

    @GET
    @Path("{id}")
    Response inquire(@PathParam("id") String id);

    @GET
    @Path("{id}\aaa")
    Response inquire(@PathParam("id") String id);

    @GET
    @Path("{id}\bbb")
    Response inquire(@PathParam("id") String id);

    @POST
    @Path("{id}")
    Response update(@PathParam("id") String id, Instruction instruction);

任何方式如何

  1. 具有相同路径的GET和POST端点具有不同的拦截器配置?
  2. 有路径变量的端点有不同的拦截器配置?使用像“/ path / * / aaa”这样的掩码?
java spring cxf
1个回答
0
投票

我在第一个问题中并不完全理解你想要的东西。但是如果你想用相同的路径声明GET和POST方法,它的工作。 JAX-RS有@PathParam注释,它从请求中的路径得到参数。使用if语句可以创建不同的逻辑。

© www.soinside.com 2019 - 2024. All rights reserved.