Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 此应用程序没有/error的显式映射,因此您将其视为未找到的回退404_Spring Boot_Spring Mvc_Jsp - Fatal编程技术网

Spring boot 此应用程序没有/error的显式映射,因此您将其视为未找到的回退404

Spring boot 此应用程序没有/error的显式映射,因此您将其视为未找到的回退404,spring-boot,spring-mvc,jsp,Spring Boot,Spring Mvc,Jsp,我的控制台,它基本上进入请求内部并打印SOP,但页面没有呈现 **击中后http://localhost:8082/user,它正在打印控制台的最后两行** :: Spring Boot :: (v2.3.4.RELEASE) 2020-10-03 13:05:41.888 INFO 836 --- [ main] com.pp.config.Application : Starting Application on DESK

我的控制台,它基本上进入请求内部并打印SOP,但页面没有呈现 **击中后http://localhost:8082/user,它正在打印控制台的最后两行**

 :: Spring Boot ::        (v2.3.4.RELEASE)

2020-10-03 13:05:41.888  INFO 836 --- [           main] com.pp.config.Application                : Starting Application on DESKTOP-26RP3TJ with PID 836 (D:\Oxygen Spring Boot\BootParent\BootWeb\target\classes started by hp in D:\Oxygen Spring Boot\BootParent\BootWeb)
2020-10-03 13:05:41.888  INFO 836 --- [           main] com.pp.config.Application                : No active profile set, falling back to default profiles: default
2020-10-03 13:05:43.702  INFO 836 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8082 (http)
2020-10-03 13:05:43.723  INFO 836 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-10-03 13:05:43.723  INFO 836 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-10-03 13:05:43.938  INFO 836 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-10-03 13:05:43.938  INFO 836 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1925 ms
2020-10-03 13:05:44.313  INFO 836 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-10-03 13:05:44.672  INFO 836 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8082 (http) with context path ''
2020-10-03 13:05:44.688  INFO 836 --- [           main] com.pp.config.Application                : Started Application in 3.403 seconds (JVM running for 3.999)
2020-10-03 13:05:51.502  INFO 836 --- [nio-8082-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-10-03 13:05:51.502  INFO 836 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-10-03 13:05:51.515  INFO 836 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 13 ms
Inside UserController
2020-10-03 13:05:51.594  WARN 836 --- [nio-8082-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Path with "WEB-INF" or "META-INF": [WEB-INF/jsp/user.jsp]
我的控制器

pom.xml

应用程序属性


如果有人能帮助我,请告诉我,谢谢你

如果你使用JSP,你的
pom.xml
应该有
war
包装。Maven不使用Jar打包的
webapp
目录。实际上,我有两个模块BootService和BootWeb,上面一个是BootService pom.xml,我已经将所有这些Jar传递到BootWeb,这是一个war pom。请共享一个到存储库的链接,以便我们可以查看所有代码并自己尝试
@Controller
public class UserController {
    @RequestMapping("/user")
    public ModelAndView firstPage() {
        System.out.println("Inside UserController");
        return new ModelAndView("user");

    }

}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.parent</groupId>
        <artifactId>BootParent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>BootService</artifactId>

    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>


        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
            <version>2.2</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.3.4.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
            <version>2.3.4.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <version>9.0.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <version>2.3.4.RELEASE</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.3.4.RELEASE</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
USER Here
</body>
</html>
@SpringBootApplication
@ComponentScan("com.pp")
public class Application extends SpringBootServletInitializer {

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);

    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);

    }
spring.datasource.url= jdbc:mysql://localhost:3306/springboot
spring.datasource.username=root
spring.datasource.password=******
spring.jpa.hibernate.ddl-auto=create-drop
server.port=8082
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp