在使用我创建的api时获得415不支持的媒体类型

时间:2018-03-18 04:38:52

标签: spring spring-mvc spring-restcontroller

varlist <- list(var1, var2, var3)

mlist <- lapply(varlist, function(x) {
     lmer(substitute(y ~ x1*x2*i + (1|ID), 
     list(i = as.name(x))), data = df)
 })

mlist_summ <- lapply(mlist, summary)

# how can I save mlist_summ in files? How can I give them different file names? 
# I have tried the following:

for(i in mlist_summ){
   stargazer(i$coefficients, type = "text", out = ... )
}

}

我使用的请求正文是

@RequestMapping(value="/sam", method=RequestMethod.POST, consumes = {"text/plain", "application/*"})
public void test(HttpServletRequest request, HttpServletResponse response, @RequestBody Test test) {
    try {System.out.println("*******************inside**************************");
    } catch(Exception exception) {
        exception.printStackTrace();
    }
}

public class Test {

private String desc;
private int id;
public String getDesc() {
    return desc;
}
public void setDesc(String desc) {
    this.desc = desc;
}
public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}

即使我在请求映射中添加了消耗,但当我尝试从邮递员访问时我得到415,并且我已经在邮递员中设置了请求标头,内容类型为application / json

1 个答案:

答案 0 :(得分:0)

我错过了json转换器库,所以当我在我的pom.xml中添加jackson-databind maven依赖时,它有效。