将 WebService (JAX-RS) 与 Java Stripes 集成

发布于 2024-12-03 00:50:29 字数 143 浏览 0 评论 0原文

我有一个用 Stripes 开发的 Web 应用程序。现在我需要在同一个应用程序中开发 RESTful Web 服务(可能使用 JAX-RS)。如何集成我的 Stripes 应用程序来包含这些 Web 服务,是否有任何可用的示例,或者除 JAX-RS 之外的任何其他方法?

I have a web application developed in Stripes. Now I need to develop RESTful webservices (probably using JAX-RS) in the same app. How do I integrate my Stripes application to contain these webservices, is there any sample available, or any other method other than JAX-RS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心凉怎暖 2024-12-10 00:50:29

由于 Stripes 是一个 Web 应用程序框架(即主要是表示层),而 JAX-RS 是一种用于执行 RESTful Web 服务的标准(即主要是业务逻辑层),因此我很想拥有两个单独的 servlet,一个用于条纹部分和 JAX-RS 部分的一个。然后,Stripes 部分将访问其后端的 JAX-RS 部分。

可能可以将这两个部分部署在同一个容器中,但我对此没有太多经验。

(您需要尽早选择要使用的 JAX-RS 实现。我知道的是 Jersey 和 CXF,它们有足够的差异(由不同的用例集驱动),您不会想要在它们之间切换。)

As Stripes is a web application framework (i.e., mainly presentation tier) whereas JAX-RS is a standard for doing RESTful web services (i.e., mainly business logic tier), I'd be strongly tempted to have two separate servlets, one for the Stripes part and one for the JAX-RS part. The Stripes part would then access the JAX-RS part for its back-end.

It is probably possible to deploy both parts in the same container, but I've not a lot of experience with that.

(You'll want to select which JAX-RS implementation you're using fairly early. The ones I know of are Jersey and CXF, and they have enough differences — driven from different sets of use cases — that you won't want to switch between them.)

南汐寒笙箫 2024-12-10 00:50:29

我现在也有同样的问题。 JAX-WS servlet 应该与 Stripes servlet 结合使用,这就是问题所在。

web.xml 摘录:

<servlet>
    <servlet-name>StripesDispatcher</servlet-name>
    <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<filter-mapping>
    <filter-name>StripesFilter</filter-name>
    <servlet-name>StripesDispatcher</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping> 

<servlet-mapping>
    <servlet-name>StripesDispatcher</servlet-name>
    <url-pattern>*.action</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>WebConnectorService</servlet-name>
    <servlet-class>my.sample.application.WebConnectorService</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>WebConnectorService</servlet-name>
    <url-pattern>/ws</url-pattern>
</servlet-mapping>

在这种情况下,JAX-WS servlet 正在工作,但所有其他请求都不会由 Stripes 处理。
有人对此问题有任何新的更新吗?谢谢。

更新:我发现请求是由两个 servlet 处理的,但问题是因为现在应用程序的上下文根等于 WAR 包的名称。不过,我

<context-root>/</context-root>

在 jboss-web.xml 中,它的行为符合预期,以防不包含 WebConnector servlet。一旦 WebConnector servlet 包含在 web.xml 中,上面的配置就会被忽略。

I have the same problem now. JAX-WS servlet should work in combination with Stripes servlet and here is the problem.

web.xml excerpt:

<servlet>
    <servlet-name>StripesDispatcher</servlet-name>
    <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<filter-mapping>
    <filter-name>StripesFilter</filter-name>
    <servlet-name>StripesDispatcher</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping> 

<servlet-mapping>
    <servlet-name>StripesDispatcher</servlet-name>
    <url-pattern>*.action</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>WebConnectorService</servlet-name>
    <servlet-class>my.sample.application.WebConnectorService</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>WebConnectorService</servlet-name>
    <url-pattern>/ws</url-pattern>
</servlet-mapping>

In this case JAX-WS servlet is working but all the other requests are not processed by Stripes.
Does anybody have any new updates to the issue? Thanks.

UPDATE: I have figured out that requests were processed by both servlets however the problem is because now the application has context root equal to the name of the WAR package. However I have

<context-root>/</context-root>

in jboss-web.xml and it behaves as expected in case WebConnector servlet is not included. As soon as WebConnector servlet is included in web.xml, the configuration above is ignored.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文