Tapestry + REST

Ale*_*lex 10 rest tapestry

我想在我的tapestry项目中添加REST,因此需要知道如何实现它.

有什么更好的方法?

谢谢.

[编辑,从答案中复制:]我必须将GET,PUT,POST和DELETE服务添加到我的tapestry应用程序中.我看到Tapestry有RESTful url但是JAX-RS和注释呢?

Hen*_*ing 11

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

要让Web服务与Tapestry完美共存,您必须在Tapestry应用程序模块中配置一件事:

/**
 * 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/.*");
}
Run Code Online (Sandbox Code Playgroud)

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

这是一个片段,显示您的web.xml应该与Tapestry和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>
Run Code Online (Sandbox Code Playgroud)

这应该可以帮助你开始.


Tim*_*per 9

如果要将REST Web服务集成到Tapestry项目中,那么Tapestry的RESTful URL可能还不够.

可以通过此Tynamo模块RESTEasy集成到Tapestry中.RESYEasy兼容JAX-RS.

我没有在Tapestry中使用RESTEasy,但是使用Spring 2.5,它运行得非常好.