小编Raj*_*ani的帖子

严重:找不到媒体类型= application/json的MessageBodyWriter,type = class com.jersey.jaxb.Todo,genericType = class com.jersey.jaxb.Todo

我正在尝试创建一个RESTful Web服务,我创建了一个,但我得到了一个

找不到媒体类型= application/json错误的MessageBodyWriter

我的Todo班级:

package com.jersey.jaxb;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.pojomatic.Pojomatic;
import org.pojomatic.annotations.AutoProperty;

@XmlRootElement
@XmlType(name = "todo")
@XmlAccessorType(XmlAccessType.FIELD)
@AutoProperty
public class Todo {

    @XmlElement(name = "summary")
    private final String summary;

    @XmlElement(name = "description")
    private final String description;

    public String getSummary() {
        return summary;
    }

    public String getDescription() {
        return description;
    }

    public Todo() {
        this(new Builder());    
    }

    public Todo(Builder builder) {
        this.summary = builder.summary;
        this.description = builder.description;
    }

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

java rest json jax-rs jersey

32
推荐指数
3
解决办法
7万
查看次数

标签 统计

java ×1

jax-rs ×1

jersey ×1

json ×1

rest ×1