春ブーツThymeleafコントローラによって返されるビューに文字列を表示します

ラファエルObadia:

私は私が私の見解で私のAPI関数の戻り値を表示する必要がある、私の見解に苦しんでいます:

春コントローラコード

@Controller
public class mainController {

  @RequestMapping(value = {"/"}, method = RequestMethod.GET)
  public String index() throws IOException, GeneralSecurityException {
    DriveQuickstart drive = new DriveQuickstart("c:/temp/credentials.json");
    String res = drive.checkFile("cwg");

    return res;

drive.checkFile返すAPI関数ですString

私は私のビューに表示する必要がありますindex.htmlどうもうありがとう。

TheSprinter:

あなたの方法は、以下のように更新します。

@RestController
public class mainController {

  @RequestMapping(value = "/", method = RequestMethod.GET)
  public String index() throws IOException, GeneralSecurityException {
    DriveQuickstart drive = new DriveQuickstart("c:/temp/credentials.json");
    String res = drive.checkFile("cwg");

    return res;
}

私が行った変更は、次のとおりです。置き換える@Controller@RestControllerし、更新します@RequestMapping

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=232416&siteId=1