求教eclipse搭建spring mvc平台tomcat不能运行问题(新手级)
按照教程步骤:用eclipse创建一个web工程,复制spring 包到lib目录,修改web.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" 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_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>springmvc002</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>springmvc01</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>springmvc01</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
创建springmvc01-serverlet.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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<!-- 启用spring mvc 注解 -->
<context:annotation-config />
<!-- 设置使用注解的类所在的jar包 -->
<context:component-scan base-package="controller"></context:component-scan>
<bean class="org.springframework.web.servlet.mvc.support.ControllerBeanNameHandlerMapping" />
<!-- 完成请求和注解POJO的映射 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/" p:suffix=".jsp" />
</beans>
再创建index.jsp文件,运行tomcat服务型,提示错误“Server Tomcat v7.0 Server at localhost failed to start.”。
尝试解决方法:
1、刷新工程,添加spring包到“java build path”的libraries下,问题没解决;
2、删除spring-core包或者spring-beans包其中一个,tomcat服务器正常启动,但spring后续代码因缺包无法运行。
3、把spring包与java包放一起也同样出现服务器无法启动;
4、更换电脑,也无法解决
因此特求大侠们帮忙分析原因并提供解决方法,谢谢了!!!!