有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在Spring Boot EleAF控制器返回的视图中显示字符串

我正在视图中挣扎,我需要在视图上显示API函数的返回:

Spring Controller Code

@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是一个返回String的API函数

我需要在我的视图上显示它。 非常感谢你,穆奇


共 (1) 个答案

  1. # 1 楼答案

    @GetMapping("/")
    public String index(Model model) throws IOException, GeneralSecurityException {
            DriveQuickstart drive = new DriveQuickstart("c:/temp/credentials.json");
            model.addAttribute("drive", drive)
        return "/routeToTemplate";
        }
    

    在特里梅莱夫

    <div th:text="${drive}"></div>