本文介绍了挂毯 + 休息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 REST 添加到我的挂毯项目中,因此需要知道如何实现它.

I want to add REST to my tapestry project, and so need to know how to implement it.

什么是更好的方法?

谢谢.

我必须将 GET、PUT、POST 和 DELETE 服务添加到我的挂毯应用程序中.我看到 Tapestry 有 RESTful url,但 JAX-RS 和注释呢?

I have to add GET, PUT, POST and DELETE services to my tapestry application. I see that Tapestry has RESTful url but what about JAX-RS and annotations?

推荐答案

您可以使用 Restlet API 或任何其他可以作为 servlet 运行的 JAX-RS 实现.

You could use the Restlet API or any other JAX-RS implementation that can run as a servlet.

为了让 Web 服务与 Tapestry 很好地共存,您必须在 Tapestry 应用模块:

To have the web service co-exist nicely with Tapestry, there is one thing you have to configure in your Tapestry application module:

/**
 * Keep Tapestry from processing requests to the web service path.
 * 
 * @param configuration {@link Configuration}
 */
public static void contributeIgnoredPathsFilter(
        final Configuration<String> configuration) {
    configuration.add("/ws/.*");
}

此代码段告诉 Tapestry 过滤器不要处理对 Web 服务所在的/ws/路径的请求.

This snippet tells the Tapestry filter not to handle requests to the /ws/ path where the web service is located.

下面的片段展示了使用 Tapestry 和 Restlet Servlet 时您的 web.xml 应该是什么样子:

Here's a snippet showing what your web.xml should approximately look like with Tapestry plus a Restlet Servlet:

<filter>
    <filter-name>app</filter-name>
    <filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>app</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Restlet adapter -->
<servlet>
    <servlet-name>WebService</servlet-name>
    <servlet-class>
        com.noelios.restlet.ext.spring.SpringServerServlet
    </servlet-class>

    ...
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>WebService</servlet-name>
    <!-- This path must also be set in AppModule#contributeIgnoredPathsFilter,
        otherwise Tapestry, being a request filter, will try to handle 
        requests to this path. -->
    <url-pattern>/ws/*</url-pattern>
</servlet-mapping>

这应该可以帮助您入门.

That should help you get started.

这篇关于挂毯 + 休息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 20:07