gpt4 book ai didi

spring - 此应用程序没有明确的/错误映射,因此您将其视为后备。 - Spring 启动 - JSP

转载 作者:行者123 更新时间:2023-11-28 22:46:41 24 4
gpt4 key购买 nike

我是 Spring Boot 的新手,尝试使用 JSP 和 Spring Boot 构建一个 Web 应用程序,得到回退错误我已经给出了准确的路径。

请引用以下链接。我创建 WEb_INF 和路径的地方 https://drive.google.com/file/d/1-qkoy49zIZe-Y6-zPeAn9g2aRGaDHt01/view?usp=sharing

文件 CustomerContoller.java

package com.javabrains.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/customer")
public class CustomerController {

public String hello(ModelMap Model) {
return "list";
}
}

文件 application.properties

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

文件 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- Look up parent from repository -->
</parent>
<groupId>com.javabrains</groupId>
<artifactId>javabrains</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>WebDemo</name>
<description>Demo project for Spring Boot</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

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

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<scope>provided</scope>
</dependency>

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

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

堆栈跟踪

  .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.8.RELEASE)

2019-09-08 11:32:00.571 INFO 6484 --- [ restartedMain] com.javabrains.WebDemoApplication : Starting WebDemoApplication on NagaTeja with PID 6484 (C:\Users\nagat\workspace1\WebDemo\target\classes started by nagat in C:\Users\nagat\workspace1\WebDemo)
2019-09-08 11:32:00.575 INFO 6484 --- [ restartedMain] com.javabrains.WebDemoApplication : No active profile set, falling back to default profiles: default
2019-09-08 11:32:00.626 INFO 6484 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-09-08 11:32:00.626 INFO 6484 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-09-08 11:32:01.644 INFO 6484 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$b5bc3870] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-08 11:32:01.699 INFO 6484 --- [ restartedMain] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2019-09-08 11:32:02.286 INFO 6484 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-09-08 11:32:02.321 INFO 6484 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-09-08 11:32:02.322 INFO 6484 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.24]
2019-09-08 11:32:02.605 INFO 6484 --- [ restartedMain] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-09-08 11:32:02.612 INFO 6484 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-09-08 11:32:02.613 INFO 6484 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1987 ms
2019-09-08 11:32:02.904 INFO 6484 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-09-08 11:32:03.235 INFO 6484 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2019-09-08 11:32:03.310 INFO 6484 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-09-08 11:32:03.313 INFO 6484 --- [ restartedMain] com.javabrains.WebDemoApplication : Started WebDemoApplication in 3.191 seconds (JVM running for 3.903)
2019-09-08 11:32:16.663 INFO 6484 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-09-08 11:32:16.663 INFO 6484 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-09-08 11:32:16.671 INFO 6484 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 8 ms

我希望 list.jsp 文件能够成功运行,不会出现任何问题。我该如何解决这个问题?

最佳答案

没有任何事情发生,因为您还没有在 Controller 中的方法上添加任何映射。所以在方法上添加一个 map ,比如

@GetMapping(value="")
public String hello(ModelMap Model) {
return "list";
}

运行项目后,打开浏览器并点击 localhost:8080/customer

关于spring - 此应用程序没有明确的/错误映射,因此您将其视为后备。 - Spring 启动 - JSP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57839653/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com