Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法反序列化START_数组-JSON/Spring MVC之外的对象实例_Java_Android_Json - Fatal编程技术网

Java 无法反序列化START_数组-JSON/Spring MVC之外的对象实例

Java 无法反序列化START_数组-JSON/Spring MVC之外的对象实例,java,android,json,Java,Android,Json,我编写了一个连接到数据库的简单web应用程序。我在android上有一个应用程序,它发送请求以获取数据库的内容 一开始我使用了一个普通的字符串,但很快就意识到它没有给我任何东西,我必须使用hibernate创建的类对象 我的异步任务有一个代码: private class DatabaseLoaderTask extends AsyncTask<Void, Void, Void> { TextView testText; TacticsEntity

我编写了一个连接到数据库的简单web应用程序。我在android上有一个应用程序,它发送请求以获取数据库的内容

一开始我使用了一个普通的字符串,但很快就意识到它没有给我任何东西,我必须使用hibernate创建的类对象

我的异步任务有一个代码:

private class  DatabaseLoaderTask extends AsyncTask<Void, Void, Void> {

        TextView testText;
        TacticsEntity content = new TacticsEntity();

        @Override
        protected void onPreExecute() {
            testText = (TextView) findViewById(R.id.textView);
        }

        @Override
        protected Void doInBackground(Void... urls) {
            RestTemplate restTemplate = new RestTemplate();
            content = restTemplate.getForObject("http://192.168.0.105:8080/SpringMVCApp/api/tactics", TacticsEntity.class);
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    testText.setText(content.getId());
                }
            });
            return null;
        }
    }
在我看来,这可能是因为我的Web应用程序返回一个数组:

  @ResponseBody
    @RequestMapping(value = "/api/tactics", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public Object[] listTacticsJson(ModelMap model) throws JSONException {
        return tacticsRepository.findAll().toArray();
    }
TacticsRepository类:

package com.springapp.mvc;

import org.springframework.data.jpa.repository.JpaRepository;

public interface TacticsRepository extends JpaRepository<TacticsEntity, Long> {
}
package com.springapp.mvc;
导入org.springframework.data.jpa.repository.JpaRepository;
公共接口策略存储库扩展了JpaRepository{
}
有没有办法解决这个问题

package com.springapp.mvc;

import org.springframework.data.jpa.repository.JpaRepository;

public interface TacticsRepository extends JpaRepository<TacticsEntity, Long> {
}