簡體   English   中英

Tomcat 控制台正在運行,但顯示“頁面未找到錯誤 404”

[英]Tomcat console is running, but displaying "page not found error 404"

運行服務器后,我在控制台中遇到的錯誤如下。 我真的不認為,這是一個錯誤,正如它所說,服務器已啟動並正在運行。 我使用動態 Web 模塊作為 2.5、Tomcat 7.0 和 Java 1.8。 我曾嘗試更改為 3.0,但也遇到了動態 Web 模塊錯誤的問題。 你還可以建議我在開發 Web 應用程序時使用的最佳組合嗎? 我還將向您展示 pom.xml 文件中使用的依賴項。 每次更新項目時,我還將 Maven 依賴項添加到“部署程序集”。

提前致謝。

Oct 31, 2017 4:04:25 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:spring-tutorial-73' did not find a matching property.
Oct 31, 2017 4:04:25 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:logins' did not find a matching property.
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/7.0.81
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Aug 11 2017 10:21:27 UTC
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         7.0.81.0
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 10
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.0
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jdk1.8.0_141\jre
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_141-b15
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         C:\Users\S528130\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp3
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\Program Files\apache-tomcat-7.0.81
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\S528130\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp3
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files\apache-tomcat-7.0.81
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\S528130\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp3\wtpwebapps
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files\apache-tomcat-7.0.81\endorsed
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Oct 31, 2017 4:04:25 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_141\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:/Program Files/Java/jdk1.8.0_141/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_141/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_141/bin/../jre/lib/amd64;C:\Program Files\apache-maven-3.5.0\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Java\jdk1.8.0_141\bin;C:\Users\S528130\Desktop;;.
Oct 31, 2017 4:04:25 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Oct 31, 2017 4:04:25 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Oct 31, 2017 4:04:25 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1014 ms
Oct 31, 2017 4:04:25 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 31, 2017 4:04:25 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.81
Oct 31, 2017 4:04:26 PM org.apache.catalina.startup.TldConfig execute
INFO: 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.
Oct 31, 2017 4:04:26 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Oct 31, 2017 4:04:26 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'log'
Oct 31, 2017 4:04:26 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'log': initialization started
Oct 31, 2017 4:04:26 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'log-servlet': startup date [Tue Oct 31 16:04:26 CDT 2017]; root of context hierarchy
Oct 31, 2017 4:04:27 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/log-servlet.xml]
Oct 31, 2017 4:04:27 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for @ControllerAdvice: WebApplicationContext for namespace 'log-servlet': startup date [Tue Oct 31 16:04:26 CDT 2017]; root of context hierarchy
Oct 31, 2017 4:04:28 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for @ControllerAdvice: WebApplicationContext for namespace 'log-servlet': startup date [Tue Oct 31 16:04:26 CDT 2017]; root of context hierarchy
Oct 31, 2017 4:04:28 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/**] onto handler 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0'
Oct 31, 2017 4:04:28 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'log': initialization completed in 1369 ms
Oct 31, 2017 4:04:29 PM org.apache.catalina.startup.TldConfig execute
INFO: 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.
Oct 31, 2017 4:04:29 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Oct 31, 2017 4:04:29 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Oct 31, 2017 4:04:29 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Oct 31, 2017 4:04:29 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Tue Oct 31 16:04:29 CDT 2017]; root of context hierarchy
Oct 31, 2017 4:04:29 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [com/caveofprogramming/spring/web/config/dao-context.xml]
Oct 31, 2017 4:04:29 PM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Oct 31, 2017 4:04:29 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [com/caveofprogramming/spring/web/config/service-context.xml]
Oct 31, 2017 4:04:29 PM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Oct 31, 2017 4:04:29 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@68b78425: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,offersDao,dataSource,offersService,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
Oct 31, 2017 4:04:29 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 516 ms
Oct 31, 2017 4:04:29 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'offers'
Oct 31, 2017 4:04:29 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'offers': initialization started
Oct 31, 2017 4:04:29 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'offers-servlet': startup date [Tue Oct 31 16:04:29 CDT 2017]; parent: Root WebApplicationContext
Oct 31, 2017 4:04:29 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/offers-servlet.xml]
Oct 31, 2017 4:04:29 PM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Oct 31, 2017 4:04:29 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7c57f80: defining beans [homeController,offersController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,jspViewResolver,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@68b78425
Oct 31, 2017 4:04:29 PM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.caveofprogramming.spring.web.controllers.HomeController.showHome()
Oct 31, 2017 4:04:29 PM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/offers],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.caveofprogramming.spring.web.controllers.OffersController.showOffers(org.springframework.ui.Model)
Oct 31, 2017 4:04:29 PM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/createoffer],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.caveofprogramming.spring.web.controllers.OffersController.createOffer(org.springframework.ui.Model)
Oct 31, 2017 4:04:29 PM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/test],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.caveofprogramming.spring.web.controllers.OffersController.showTest(org.springframework.ui.Model,java.lang.String)
Oct 31, 2017 4:04:29 PM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/docreate],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.caveofprogramming.spring.web.controllers.OffersController.doCreate(org.springframework.ui.Model,com.caveofprogramming.spring.web.dao.Offer,org.springframework.validation.BindingResult)
Oct 31, 2017 4:04:29 PM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 5.0.1.Final
Oct 31, 2017 4:04:30 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/static/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
Oct 31, 2017 4:04:30 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'offers': initialization completed in 779 ms
Oct 31, 2017 4:04:30 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Oct 31, 2017 4:04:30 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 31, 2017 4:04:30 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4904 ms

日志servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">



    <context:component-scan base-package="com.logins.Controllers"></context:component-scan>
    <mvc:annotation-driven></mvc:annotation-driven>
    <mvc:default-servlet-handler/>
    <bean id="jspViewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsps"></property>
    <property name="suffix" value=".jsp"></property>
    </bean>
</beans>

網頁.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>logins</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>log</display-name>
    <servlet-name>log</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>log</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

使用的依賴項的 pom.xml 文件。

<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>
  <groupId>logins</groupId>
  <artifactId>logins</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
  </dependencies>
</project>

該日志中實際上沒有任何內容是錯誤的,都是出於調試目的的詳細輸出,您擔心什么? 是否有問題,或者您只是認為那里有堆棧跟蹤並決定發布問題?

修復我的答案是 log-servlet.xml 前綴值->“/WEB-INF/jsps”

    <context:component-scan base-package="com.logins.Controllers"></context:component-scan>
    <mvc:annotation-driven></mvc:annotation-driven>
    <mvc:default-servlet-handler/>
    <bean id="jspViewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsps/"></property>
    <property name="suffix" value=".jsp"></property>
    </bean>
</beans>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM