java - Spring-boot Rest api页面调用

标签 java rest spring-boot

我有一个简单的 Spring Boot 应用程序。我正在尝试通过休息 Controller 加载 html 文件。下面是我的文件夹结构。我无法加载 test.html (就像其中的 helloworld 代码一样)

enter image description here

@RequestMapping("/show1")
public ModelAndView showpage1() {
    System.out.println("## show1");
    ModelAndView modelAndView = new ModelAndView();
     modelAndView.setViewName("test");
     return modelAndView;
}

我的test.html内容

<h1> hello World </h1>

最佳答案

尝试这样做:

 @RequestMapping("/show1")
            public String showpage1() {
                return "test";
            } 

其中 test.html 是您的页面

关于java - Spring-boot Rest api页面调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60273814/

相关文章:

java - 多动态时间事件监听器

rest - 更安静的上传文件方式

spring-boot - 2.7 中的 Spring 执行器不可用,得到 404

java - 二级缓存 + Spring Boot + Java Hibernate 中的问题

java - 打印并行运行的多个 SSH 命令的输出

java - Java中如何动态初始化数组?

Java @Pathparam 与 POST 方法

java - REST 问题 com.sun.jersey.api.container.ContainerException : The ResourceConfig instance does not contain any root resource classes

spring-boot - 来自 Tomcat 的 Spring Boot 配置文件位置

java - 如何增加tomcat中的最大堆大小? catalina.sh 有很多引用资料