运行应用程序时,我会收到下面的控制台消息,但每次导航到http://localhost:8080/?我收到一条错误消息,上面写着:
"白标签错误页此应用程序没有/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```
确保已为请求的url"/"
定义了Controller
,如下所示:
@RequestMapping("/")
public String homePage() {
... <your code>
return "home";
}
并且,您的home
页面必须存储在以下路径中:
|--resources
|--templates
|--home.html
当您正在搜索的URL没有页面时,就会出现白标签错误。所以在你的控制器中查看是否存在"0"的映射/&";。
白色错误标签是没有任何控制器路径的空Spring应用程序的预期行为。除非您没有配置任何REST路径或端点,否则会显示此错误。
如果错误仍然存在,请确保您的主应用程序类扩展了SpringBootServletInitializer,并且您正在编写适当的端点路径。