问题标签 [resteasy]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
12532 浏览

servlets - 轻松休息和初始化参数 - 如何访问?

我想在我的 web.xml 中有一些初始化参数并稍后在应用程序中检索它们,我知道当我有一个普通的 servlet 时我可以做到这一点。但是,使用 resteasy,我将 HttpServletDispatcher 配置为我的默认 servlet,所以我不太确定如何从我的休息资源中访问它。这可能很简单,或者我可能需要使用不同的方法,无论哪种方式,了解你们的想法都会很好。以下是我的 web.xml,

我的问题是如何在 init-param 中设置一些东西,然后稍后在一个安静的资源中检索它。任何提示将不胜感激。多谢你们!

0 投票
1 回答
9073 浏览

java - RESTEasy will not map my Spring bean with custom Spring ContextLoader

  • RESTEasy 2.0.1GA
  • Java 1.6
  • Spring 3.0.3

I have tried everything I can, and cannot make head or tail of what's going on. I have a Spring MVC application, however I'd like to have some RESTEasy endpoints available outside the Spring MVC app, but in the same container, ultimately being able to wire in the same beans.

As a first step, I'm simply trying to stand-up RESTEasy inside the container, serving requests from a Spring-configured bean. I have tried the boilerplate from the instructions and have also tried manual setup, to no avail.

Bean

web.xml

applicationContext.xml

According to the documentation, all I have to do is “manually register the RESTeasy BeanFactoryPostProcessor by allocating an instance of org.jboss.resteasy.plugins.spring.SpringBeanProcessor”. I believe this spring configuration does that.

Jetty starts and the app context spins up with no issues. Application works normally, however when I

("ei" is the application context). The log shows (this and only this):

Even if I could convince RESTEasy to show me the mappings, it seems that it's just not discovering my bean.

If I map it explicitly via the resteasy.resources context param, it works, though obviously doesn't have access to auto-wired Spring beans.

Anything else I can try? I have debug log on the entire RESTEasy codebase and I don't get any messages. I've also confirmed that Spring is, in fact, creating my bean, so it's just that RESTEasy isn't finding it.

0 投票
1 回答
3969 浏览

json - 过滤 RESTEasy json 翻译 - 我不想发送每个字段!

我正在使用 RESTEasy 通过我的带有 JSON 的 rest api 发送对象。这非常方便 - 每个字段都会自动填充到 JSON 对象中。但是有些字段(例如passwordhash)我宁愿不发送。我还想删除任何空值 - 无需发送这些值。

我可以影响 JSON 的创建方式吗?

我正在使用 Jettison、RESTEasy 2.0.1.GA 和我认为的 JAXB,尽管我确实很难确定这一点。

0 投票
3 回答
7551 浏览

java - RESTEasy 隐藏了真正的异常

我的代码抛出异常(由于错误)。在日志中,我看到:

不记录实际异常的堆栈。如果我将代码包装在 a 中try..catch并记录捕获的异常,我可以验证我的代码是否有问题。我的系统中没有其他库可以做到这一点,即使对于深度包装的异常也是如此,所以它一定是 RESTEasy 中的问题,也许在UnhandledException?

有没有办法解决这种行为?我想不出一个很好的理由为什么它应该隐藏实际的异常。

  • 码头
  • 爪哇
  • 春天 3.0.3
  • RESTEasy 2.0.1GA
0 投票
1 回答
359 浏览

java - RESTEASY - 返回具有和不具有列表的相同对象

我有一个包含几个属性和一个列表的 bean。例如

我现在想要一个界面,有时会返回一个人与他们的朋友的列表,有时没有:

这些方法的实现非常相似。唯一的区别是其中一个不会包含在返回的 xml 中的好友列表中。

关于如何解决这个问题的任何想法?我最初的想法是将 Person 子类化为 PersonWithNoFriends ,它不会对 getFriends 进行注释。

谢谢,

阿萨夫

0 投票
1 回答
1912 浏览

web-services - 如何在 REST Web 服务中接收 POST 图像

公开可以接受 base64 编码图像的基于 REST 的 Web 服务的一般方法是什么。我还不确定图像是 anInputStream还是ByteArray. 我正在使用 RESTEasy。我可以将其映射为@FormParam( javax.ws.rs.FormParam) 吗?传入图像的通常数据类型是什么?

0 投票
1 回答
340 浏览

web-services - resteasy 在另一个服务中调用服务

我有一个服务 X 和 Y。如果我想在 X 中调用 Y。有没有办法通过注释来做到这一点。我不想为 X/Y 配置 bean,因为所有其他资源都是为 X 自动装配的。

谢谢!

0 投票
1 回答
5294 浏览

java - 具有默认值的 Java JAX-RS 自定义参数

假设我有这个(这只是一个示例):

和用户是

如果我这样做/api/address?user=amir一切正常,但我的想法是如果我不为用户提供值,那么我希望使用 DEFAULT_USER。但这实际上并没有调用 valueOf。有没有办法来解决这个问题?

0 投票
1 回答
3133 浏览

java - 接受标头为空或未知 jax-rs 时的内容类型

接受头为空时返回的默认内容是什么?

以下代码在接受标头为空时返回 application/xml,映射到 findAll()。当接受标头为空或未知时,是否有办法强制 jax-rs 执行 findAllAtom()。我正在使用带有 Jboss 应用程序服务器和 Adbera 1.1.2 的 restEasy 版本 2

0 投票
2 回答
978 浏览

rest - 一些服务调用的 Resteasy 通用查询参数

我正在使用 Resteasy 的客户端框架,并且我有一些方法需要对服务器进行身份验证。身份验证是通过会话票证实现的,并且该票证必须作为查询参数包含在请求 URL 中。默认情况下,我需要将票证传递给我的所有服务调用,如下所示:

但我不想将票证参数传递给我的每个服务调用。我需要一种解决方案,以一种通用的方式将其设置为每个调用的查询参数。因此,我的服务调用方法只会采用除票证之外的实际服务参数。但是,当请求服务时,票证将包含在请求 URL 中。

有没有办法做到这一点?

提前致谢。