1

我正在尝试根据问题编号的请求将 JSON 返回给客户端。为此,我正在使用 Springs Rest Controller;这是控制器的外观。

    package com.questions.controllers.rest;

import java.util.ArrayList;
import java.util.List;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.questions.beans.QuestionBean;

@RestController
public class QuestionController {


    @RequestMapping("/question/{id}")
    public @ResponseBody QuestionBean loadQuestionByNumber(@PathVariable("id")int id){

        return new QuestionBean(id, "VeryLongQuestion");
    }
}

问题:我想发送一个很长的问题,而不是字符串“VeryLongQuestion”,例如 1MB data 或更多。Java 的 String 可能不支持这么大的数据。我怎么能在这里做?我想流式传输数据。我的 QuestionBean 应该包含什么?

4

0 回答 0