Springboot无法访问JSP 404问题

工程目录如下:
Springboot无法访问JSP 404问题_第1张图片
Controller

@Controller
public class TestJsp {

    @GetMapping("jsp")
    public String jsp(){
        return "index";
    }

}

配置文件

spring:
  mvc:
    view:
      prefix: /WEB-INF/jsp/
      suffix: .jsp

pom

		>
            >org.springframework.boot>
            >spring-boot-starter-tomcat>
        >
        >
            >org.apache.tomcat.embed>
            >tomcat-embed-jasper>
        >
        >
            >javax.servlet>
            >jstl>
        >

还需要加入下面这段代码

<build>
        <resources>
            <resource>
                <directory>src/main/webapp</directory>
                <targetPath>META-INF/resources</targetPath>
                <includes>
                    <include>**/**
                
            
        
    

Springboot无法访问JSP 404问题_第2张图片

你可能感兴趣的:(springboot,java,spring,boot,servlet)