我可以看到 FilterDispatcher 被调用(由调试器),但它似乎没有找到要调用的服务。我很难理解 RestEasy 是如何在 Spring 和 RestEasy 中定义的资源之间实际映射的。
主要故事:获取http://my.local.no:8087/rest/typeaheads/h仅呈现 404
网页.xml:
...
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>restFilterDispatcher</filter-name>
<filter-class>org.jboss.resteasy.plugins.server.servlet.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>restFilterDispatcher</filter-name>
<url-pattern>/rest/*</url-pattern>
</filter-mapping>
...
resteasy资源由bean设置:
@Configuration
@ComponentScan(basePackageClasses = TypeaheadsRestService.class)
public class SpringConfig {
}
TypeaheadsRestService.java:
@Resource
@Path("/typeaheads")
public class TypeaheadsRestService {
@GET
@Path("/{search}")
@Produces(MediaType.APPLICATION_JSON)
public List<NameUrl> get(@PathParam("search") String search) {
...
}
}