首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Quarkus -找不到内容类型应用程序/x-www-form-urlencoded类型的作者。

Quarkus -找不到内容类型应用程序/x-www-form-urlencoded类型的作者。
EN

Stack Overflow用户
提问于 2022-03-03 10:47:22
回答 1查看 1.2K关注 0票数 0

这是我使用jax-rs客户机执行请求的代码:

代码语言:javascript
复制
private Client client;

private static final int TIMEOUT = 8000;

@PostConstruct
public void init() {
    client = ClientBuilder.newBuilder()
            .readTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
            .connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
            .build();
}

……

代码语言:javascript
复制
final String resource = "/some-endpoint/{id}/securityinfo";
final String path = url + resource;

final WebTarget target = client
        .target(path)
        .resolveTemplate("id", email);

final var form = new Form().param("mail", email);

final Response response = target
        .request()
        .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED));

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
    throw new MyException(response.readEntity(String.class));
}

我收到错误:

javax.ws.rs.ProcessingException: RESTEASY004655:无法调用请求: javax.ws.rs.ProcessingException: RESTEASY003215:无法为内容类型的应用程序/x-www-form-urlencoded类型: javax.ws.rs.core.Form找到编写器

这种情况只发生在表单内容类型请求中,因为json支持正常工作。

编辑

这些是所使用的依赖关系:

代码语言:javascript
复制
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jdbc-oracle</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jsonb</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-junit5</artifactId>
    <scope>test</scope>
</dependency>
EN

回答 1

Stack Overflow用户

发布于 2022-03-03 16:28:56

您是否尝试过使用(https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/Entity.html#form-javax.ws.rs.core.Form-):

代码语言:javascript
复制
Entity.form(form);

我不确定它能解决这个问题,因为它只是你所拥有的东西的简写。但我会试一试。

为了更容易地找到解决方案,可以共享您在项目中使用的依赖项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71335836

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档