为了账号安全,请及时绑定邮箱和手机立即绑定

跟老师的一样,找不到DispatcherServlet,一直报404,为什么?

跟老师的一样,找不到DispatcherServlet,一直报404,为什么?

一升米 2016-09-25 13:02:43
我用的tomcat,服务器一启动就会报:严重: Servlet [mvc-dispatcher] in web application [/spring-mvc-study] threw load() exceptionjava.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:518) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:499) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1027) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5038) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5348) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)九月 25, 2016 12:45:33 下午 org.apache.coyote.AbstractProtocol start为什么找不到DispatcherServlet啊??我web.xml文件如下:<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" ><web-app>  <display-name>Archetype Created Web Application</display-name>  <!-- DispatcherServlet, Spring MVC的核心 -->  <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- DispatcherServlet对应的上下文配置, 默认为/WEB-INF/$servlet-name$-servlet.xml --> <init-param>          <param-name>contextConfigLocation</param-name>          <param-value>/WEB-INF/configs/spring/mvc-dispatcher-servlet.xml</param-value>        </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc-dispatcher</servlet-name>    <!-- mvc-dispatcher拦截所有的请求--> <url-pattern>/</url-pattern> </servlet-mapping>      </web-app>我mvc-dispatcher-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/beans        http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context.xsd        http://www.springframework.org/schema/mvc        http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <!-- 本配置文件是工名为mvc-dispatcher的DispatcherServlet使用, 提供其相关的Spring MVC配置 --> <!-- 启用Spring基于annotation的DI, 使用户可以在Spring MVC中使用Spring的强大功能。  激活 @Required @Autowired,JSR 250's @PostConstruct, @PreDestroy and @Resource 等标注 --> <context:annotation-config /> <!-- DispatcherServlet上下文, 只管理@Controller类型的bean, 忽略其他型的bean, 如@Service --> <context:component-scan base-package="com.imooc.mvcdemo"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- HandlerMapping, 无需配置, Spring MVC可以默认启动。 DefaultAnnotationHandlerMapping  annotation-driven HandlerMapping --> <!-- 扩充了注解驱动,可以将请求参数绑定到控制器参数 --> <mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsps/" /> <property name="suffix" value=".jsp" /> </bean></beans>访问http://localhost:8080/spring-mvc-study这个正常显示 访问http://localhost:8080/spring-mvc-study/hello/mvc 就报404错误项目目录:我真的不认为哪里还有问题了,求大神指点
查看完整描述

4 回答

?
慕粉4075985

TA贡献104条经验 获得超33个赞

每导包?

查看完整回答
反对 回复 2017-04-06
?
cary_candy

TA贡献1条经验 获得超0个赞

照这你的代码敲了一遍 没问题啊

//img1.sycdn.imooc.com//58e60bfc0001343e18890408.jpg

//img1.sycdn.imooc.com//58e60bfd0001de4403460422.jpg

//img1.sycdn.imooc.com//58e60bfd000158be14820433.jpg


查看完整回答
反对 回复 2017-04-06
  • 4 回答
  • 0 关注
  • 6748 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信