我从这里读了很多与我的案子有同样问题的话题,但没有找到解决我问题的方法。这是我使用命名空间
的servlet配置 Jan 11, 2017 9:34:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.14
Jan 11, 2017 9:34:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Sep 24 2014 09:01:51
Jan 11, 2017 9:34:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.14.0
Jan 11, 2017 9:34:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Mac OS X
Jan 11, 2017 9:34:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.10.5
Jan 11, 2017 9:34:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: x86_64
Jan 11, 2017 9:34:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_11-b12
Jan 11, 2017 9:34:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Jan 11, 2017 9:34:17 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/dinhthinh/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Jan 11, 2017 9:34:17 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:vietduuni' did not find a matching property.
Jan 11, 2017 9:34:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8001"]
Jan 11, 2017 9:34:18 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jan 11, 2017 9:34:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Jan 11, 2017 9:34:18 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jan 11, 2017 9:34:18 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1064 ms
Jan 11, 2017 9:34:18 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 11, 2017 9:34:18 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.14
Jan 11, 2017 9:34:18 AM org.apache.jasper.servlet.TldScanner scanJars
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.
Jan 11, 2017 9:34:20 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 11, 2017 9:34:21 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Jan 11, 2017 9:34:23 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'vietjob'
Jan 11, 2017 9:34:25 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8001"]
Jan 11, 2017 9:34:25 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Jan 11, 2017 9:34:25 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 7262 ms
这是重启服务器时的stackstrace
<?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"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- Servlet config begin -->
<servlet>
<servlet-name>vietjob</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>vietjob</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- end-->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Begin load Spring Filter Chain config from servlet vietjob -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/vietjob-security.xml
</param-value>
</context-param>
<!-- end load -->
<!-- Begin Spring security config-->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
web.xml配置
{{1}}
当我运行我的应用程序时,没有发现任何错误,但在堆栈跟踪中它没有显示通知控制器已加载的文本行。所以当我点击链接时,我收到404错误。有人可以帮帮我吗?!
答案 0 :(得分:0)
您没有分享如何启动应用程序。
对于任何Spring Web应用程序,您必须在应用程序中提供DispatcherServlet的配置。
方法1 您可以将以下映射放在web.xml文件中
<servlet>
<servlet-name>myWebApp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myWebApp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
方法2 您可以注册实现接口WebApplicationInitializer的bean,并可以以编程方式注册DispatcherServlet
现在bean配置文件名应为{servlet-name} -servlet.xml
因此对于上面的servlet,bean配置文件名应该是myWebApp-servlet.xml
或者如果您想自定义bean配置文件的名称,那么您可以在web.xml中提及它,如下所示
<servlet>
<servlet-name>myWebApp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>myWebApp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
答案 1 :(得分:0)
删除pom.xml文件中的log4j12依赖项解决了我的问题。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>