WebSphere 8.5 是否内置了 JAX-RS 处理?

Does WebSphere 8.5 have built in JAX-RS handling?

关于 JAX-RS 是否内置于 WebSphere 8.5 中,IBM 支持的多个页面似乎有所不同。

http://www.ibm.com/developerworks/websphere/techjournal/1305_gunderson/1305_gunderson.html

The most recent versions of IBM WebSphere Application Server provide support for JAX-RS. WebSphere Application Server V8.5 has support for JAX-RS built in; no extra installation is required.

http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.iseries.doc/ae/twbs_jaxrs_devenv.html?cp=SSAW57_8.5.5%2F2-13-2-38-1-1&lang=en

To develop JAX-RS applications, the JAX-RS libraries must be added to the class path definition. See the information for your assembly tools to understand how to include libraries on the class path for the JAX-RS application.

WebSphere 8.5 上的 运行 JAX-RS 需要做什么。是否需要 web.xml 映射?是否需要额外的库文件?

WebSphere 8.5.5 实现了 JAX-RS 1.1 提供程序,因此您不需要任何额外的库。您可以根据需要创建或不创建映射。您的选项的最佳描述在此处 Configuring JAX-RS applications using JAX-RS 1.1 methods.

您可以:

  • 在 web.xml 文件中仅使用一个 JAX-RS 默认应用程序配置 JAX-RS 应用程序,如下所示:
<servlet>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
</servlet>
<servlet-mapping>
  <servlet-name>javax.ws.rs.core.Application</servlet-name>
  <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
  • 使用 javax.ws.rs.core.Application 子类 web.xml 文件配置 JAX-RS 应用程序:
<servlet>         
    <servlet-name>com.example.MyApplication</servlet-name> 
</servlet>
<servlet-mapping>
    <servlet-name>com.example.MyApplication</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
  • 在没有 web.xml 文件的情况下配置 JAX-RS 应用程序。您只使用 @ApplicationPath@Path 等注释
@ApplicationPath("rest")
public class MyApplication extends javax.ws.rs.core.Application {
}

@Path("/helloworld")
public class HelloWorldResource {

    @GET
    public String sayHelloWorld() {
        return "Hello World!";
    }
}