运行我的应用程序时,我得到下面的控制台消息,但是每次导航到http:// localhost:8080 /?我收到一条错误消息:
“ Whitelabel错误页面此应用程序没有针对/ error的显式映射,因此您将其视为后备。
美国东部时间2021年1月12日星期二22:04:40发生意外错误(类型=未找到,状态= 404)“
控制台输出:
2021-01-12 22:03:17.212 INFO 21710 --- [ main] com.crd.carrental.CarRentalApplication : No active profile set, falling back to default profiles: default
2021-01-12 22:03:18.343 INFO 21710 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-01-12 22:03:18.350 INFO 21710 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-01-12 22:03:18.350 INFO 21710 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39]
2021-01-12 22:03:18.424 INFO 21710 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-01-12 22:03:18.424 INFO 21710 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1073 ms
2021-01-12 22:03:18.539 INFO 21710 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientInboundChannelExecutor'
2021-01-12 22:03:18.542 INFO 21710 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientOutboundChannelExecutor'
2021-01-12 22:03:18.548 INFO 21710 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'messageBrokerTaskScheduler'
2021-01-12 22:03:18.613 INFO 21710 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'brokerChannelExecutor'
2021-01-12 22:03:19.539 INFO 21710 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-01-12 22:03:19.541 INFO 21710 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : Starting...
2021-01-12 22:03:19.541 INFO 21710 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : BrokerAvailabilityEvent[available=true, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
2021-01-12 22:03:19.541 INFO 21710 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : Started.
2021-01-12 22:03:19.551 INFO 21710 --- [ main] com.crd.carrental.CarRentalApplication : Started CarRentalApplication in 2.977 seconds (JVM running for 5.797)
2021-01-12 22:04:18.616 INFO 21710 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
2021-01-12 22:04:23.920 INFO 21710 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-01-12 22:04:23.920 INFO 21710 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-01-12 22:04:23.929 INFO 21710 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 9 ms```
确保Controller
为请求的网址定义了,"/"
如下所示:
@RequestMapping("/")
public String homePage() {
... <your code>
return "home";
}
并且,您的home
页面必须存储在以下路径中:
|--resources
|--templates
|--home.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句