質問番号のリクエストでクライアントに 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");
}
}
問題: String "VeryLongQuestion" の代わりに、非常に長い質問 (1 MB データなど) を送信したいと考えています。Java の文字列は、そのようなビッグ データをサポートしていない可能性があります。どうすればここにできますか?データをストリーミングしたい。私の QuestionBean には何を含める必要がありますか?