gpt4 book ai didi

rest - Tapestry + REST

转载 作者:行者123 更新时间:2023-12-04 03:02:38 27 4
gpt4 key购买 nike

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

有什么更好的方法?

谢谢。

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

最佳答案

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

为了使Web服务与Tapestry很好地共存,您必须在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/路径的请求。

下面的代码片段显示了Tapestry和ReSTLet Servlet的web.xml应该大致是什么样子:

<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>

那应该可以帮助您入门。

关于rest - Tapestry + REST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2765178/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com