Android Spring Boot 415上的控制器不支持的媒体类型

Android Spring Boot 415上的控制器不支持的媒体类型,android,json,spring,http,spring-boot,Android,Json,Spring,Http,Spring Boot,您好,我的控制器上的Spring Boot具有以下配置: @RequestMapping(value = "/test/setgamesets", method = RequestMethod.POST,consumes="application/json") public @ResponseBody Collection<GameSet> setGameSets(@RequestBody ArrayList<GameSet> gmsets) {

您好,我的控制器上的Spring Boot具有以下配置:

@RequestMapping(value = "/test/setgamesets", method = RequestMethod.POST,consumes="application/json")
public @ResponseBody Collection<GameSet> setGameSets(@RequestBody ArrayList<GameSet> gmsets) {
            for(GameSet gs : gmsets){
                System.out.println(""+gs.getId());
                gamesets.save(gs);          
            }
            return Lists.newArrayList(gamesets.findAll());
        }
你能给我一个提示去哪里找我的错吗

感谢您的关注和时间

日志:

11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ ---> HTTP POST https://192.168.1.65:8443/test/setgamesets
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ Authorization: Bearer 1d5deb22-a470-4443-984f-3f877b05e372
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ Content-Type: application/json
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ Content-Length: 848
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ [{"explanation":"I dont know why this is wrong.","title4":"MovieD","question":"Choose one of the following, which is wrong.","title3":"MovieC","title2":"MovieB","title1":"MovieA","id":1,"rate":1.0,"rates":4,"wrong":1},{"explanation":"I dont know why this is wrong.","title4":"MovieD","question":"What is wrong with the follow movies.","title3":"MovieC","title2":"MovieB","title1":"MovieA","id":2,"rate":1.0,"rates":5,"wrong":2},{"explanation":"I dont know why this is wrong.","title4":"MovieD","question":"What is wrong with the follow movies.","title3":"MovieC","title2":"MovieB","title1":"MovieA","id":3,"rate":1.0,"rates":5,"wrong":3},{"explanation":"I dont know why this is wrong.","title4":"MovieD","question":"What is wrong with the follow movies.","title3":"MovieC","title2":"MovieB","title1":"MovieA","id":4,"rate":0.0,"rates":0,"wrong":4}]
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ ---> END HTTP (848-byte body)
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ <--- HTTP 415 https://192.168.1.65:8443/test/setgamesets (177ms)
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Server: Apache-Coyote/1.1
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ X-Content-Type-Options: nosniff
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ X-XSS-Protection: 1; mode=block
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Cache-Control: no-cache, no-store, max-age=0, must-revalidate
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Pragma: no-cache
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Expires: 0
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Strict-Transport-Security: max-age=31536000 ; includeSubDomains
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ X-Frame-Options: DENY
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Set-Cookie: JSESSIONID=C97BD6EB007A558F69B0DA7A19615917; Path=/; Secure; HttpOnly
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ X-Application-Context: application
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Content-Type: application/schema+json
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Transfer-Encoding: chunked
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Date: Mon, 17 Nov 2014 06:43:12 GMT
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ {
    "timestamp" : 1416206592255,
    "error" : "Unsupported Media Type",
    "status" : 415,
    "message" : ""
    }
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ <--- END HTTP (112-byte body)
11-17 08:43:12.463    8287-8734/com.testing.test E/com.testing.test.CallableTask﹕ Error invoking callable in AsyncTask callable: com.testing.test.Game_Panel_Score_Activity$1@41f20a18
    retrofit.RetrofitError: 415 Unsupported Media Type

您的客户端应用程序应该包含HTTP头内容类型:application/json,以使其正常工作。但我不是安卓开发者,所以不知道怎么做

谢谢你的回复。我已经试过了,但是我得到了同样的错误。我在logcat中添加了我的代码,这可能会有所帮助。您是否真的定义了JSON转换器(即Jackson是否在服务器的类路径上)?我刚刚添加了build.gradle:
compile(“com.fasterxml.Jackson.core:Jackson-databind:2.2.3”)compile(“org.codehaus.Jackson:Jackson-mapper-asl:1.9.13”)compile(“org.codehaus.jackson:jackson core asl:1.9.13”)
但我仍然收到相同的错误。还有其他方法可以让它工作吗???为什么你同时使用jackson 1和jackson 2(我不确定这是否重要,但一个还不够)?对于您目前提供的信息,我无能为力。如果您有一个最小的项目可以在guthub上共享,它可能会很快发现问题。
retrofit.RetrofitError: 415 Unsupported Media Type
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ ---> HTTP POST https://192.168.1.65:8443/test/setgamesets
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ Authorization: Bearer 1d5deb22-a470-4443-984f-3f877b05e372
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ Content-Type: application/json
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ Content-Length: 848
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ [{"explanation":"I dont know why this is wrong.","title4":"MovieD","question":"Choose one of the following, which is wrong.","title3":"MovieC","title2":"MovieB","title1":"MovieA","id":1,"rate":1.0,"rates":4,"wrong":1},{"explanation":"I dont know why this is wrong.","title4":"MovieD","question":"What is wrong with the follow movies.","title3":"MovieC","title2":"MovieB","title1":"MovieA","id":2,"rate":1.0,"rates":5,"wrong":2},{"explanation":"I dont know why this is wrong.","title4":"MovieD","question":"What is wrong with the follow movies.","title3":"MovieC","title2":"MovieB","title1":"MovieA","id":3,"rate":1.0,"rates":5,"wrong":3},{"explanation":"I dont know why this is wrong.","title4":"MovieD","question":"What is wrong with the follow movies.","title3":"MovieC","title2":"MovieB","title1":"MovieA","id":4,"rate":0.0,"rates":0,"wrong":4}]
11-17 08:43:12.283    8287-8734/com.testing.test D/Retrofit﹕ ---> END HTTP (848-byte body)
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ <--- HTTP 415 https://192.168.1.65:8443/test/setgamesets (177ms)
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Server: Apache-Coyote/1.1
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ X-Content-Type-Options: nosniff
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ X-XSS-Protection: 1; mode=block
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Cache-Control: no-cache, no-store, max-age=0, must-revalidate
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Pragma: no-cache
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Expires: 0
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Strict-Transport-Security: max-age=31536000 ; includeSubDomains
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ X-Frame-Options: DENY
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Set-Cookie: JSESSIONID=C97BD6EB007A558F69B0DA7A19615917; Path=/; Secure; HttpOnly
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ X-Application-Context: application
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Content-Type: application/schema+json
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Transfer-Encoding: chunked
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ Date: Mon, 17 Nov 2014 06:43:12 GMT
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ {
    "timestamp" : 1416206592255,
    "error" : "Unsupported Media Type",
    "status" : 415,
    "message" : ""
    }
11-17 08:43:12.463    8287-8734/com.testing.test D/Retrofit﹕ <--- END HTTP (112-byte body)
11-17 08:43:12.463    8287-8734/com.testing.test E/com.testing.test.CallableTask﹕ Error invoking callable in AsyncTask callable: com.testing.test.Game_Panel_Score_Activity$1@41f20a18
    retrofit.RetrofitError: 415 Unsupported Media Type
@Entity
public class GameSet {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
    private String question;
    private String title1;
    private String title2;
    private String title3;
    private String title4;
    private int wrong;
    private String explanation;
    private int rates;
    private double rate;

    public GameSet() {

    }

    public GameSet(String question,String title1, String title2, String title3, String title4,String explain, int wrong) {
        super();
        this.question = question;
        this.title1 = title1;
        this.title2 = title2;
        this.title3 = title3;
        this.title4 = title4;
        this.explanation = explain;
        this.wrong = wrong;
        this.rate = 0;
        this.rates = 0;
    }

    // Getters
    public String getQuestion() {
        return question;
    }

    public String getTitle1() {
        return title1;
    }

    public String getTitle2() {
        return title2;
    }

    public String getTitle3() {
        return title3;
    }

    public String getTitle4() {
        return title4;
    }

    public String getExplanation() {
        return explanation;
    }

    public int getWrong() {
        return wrong;
    }

    public int getRates() {
        return rates;
    }

    public double getRate() {
        return rate;
    }

    // Setters

    public String setQuestion(String question) {
        return this.question = question;
    }

    public void setTitle1(String title1) {
        this.title1 = title1;
    }

    public void setTitle2(String title2) {
        this.title1 = title2;
    }

    public void setTitle3(String title3) {
        this.title1 = title3;
    }

    public void setTitle4(String title4) {
        this.title1 = title4;
    }

    public void setExplanation(String explain) {
        this.explanation = explain;
    }

    public void setWrong(int wrong) {
        this.wrong = wrong;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    public void setRates(int rate) {
        this.rate = rate;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }
}