码迷,mamicode.com
首页 > 编程语言 > 详细

Spring-MVC-所需要的jar包

时间:2017-08-31 14:39:33      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:cto   prefix   lan   app   配置   life   网上   参考   opened   

这两天因为环境搭建的问题特别苦难,参考了一下网上的各种答案,决定自己试一下Spring-MVC启动所需要的jar包;

因为Spring-MVC是在Spring框架下,索性从零开始我们引入需要的jar包;

maven下创建工程老师还没有讲解,这里采用eclipse的Dynamic Web Project来搭建环境;

首先配置web.xml

技术分享
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://xmlns.jcp.org/xml/ns/javaee"
 4     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
 5     id="WebApp_ID" version="3.1">
 6     <servlet>
 7         <servlet-name>springMVC</servlet-name>
 8         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 9         <init-param>
10             <param-name>contextConfigLocation</param-name>
11             <param-value>/WEB-INF/servlet-context.xml</param-value>
12         </init-param>
13         <load-on-startup>1</load-on-startup>
14     </servlet>
15     <servlet-mapping>
16         <servlet-name>springMVC</servlet-name>
17         <url-pattern>/</url-pattern>
18     </servlet-mapping>
19 
20     <display-name>Test</display-name>
21     <welcome-file-list>
22         <welcome-file>index.html</welcome-file>
23         <welcome-file>index.htm</welcome-file>
24         <welcome-file>index.jsp</welcome-file>
25         <welcome-file>default.html</welcome-file>
26         <welcome-file>default.htm</welcome-file>
27         <welcome-file>default.jsp</welcome-file>
28     </welcome-file-list>
29 </web-app>
View Code

 然后配置spring-MVC的xml→servlet-context.xml

技术分享
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:context="http://www.springframework.org/schema/context"
  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.xsd">

  <annotation-driven />

  <context:component-scan base-package="spitter" />

  <beans:bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
  </beans:bean>

  <resources mapping="/resources/**" location="/resources/" />

  <!-- 
  <view-controller path="/" view-name="home" />
  -->

</beans:beans>
View Code

启动项目

tomcat8.5启动报错

java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

把spring-web-4.2.3.RELEASE.jar 拖到/WEB-INF/lib/目录下,Refresh一下工程;

再次启动项目后报错

java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

把spring-webmvc-4.2.3.RELEASE.jar 拖到/WEB-INF/lib/目录下,Refresh一下工程;

再次启动项目后报错

java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextAware

把spring-context-4.2.3.RELEASE.jar 拖到/WEB-INF/lib/目录下,Refresh一下工程;

再次启动项目后报错

java.lang.ClassNotFoundException: org.springframework.beans.factory.Aware

把spring-beans-4.2.3.RELEASE.jar 拖到/WEB-INF/lib/目录下,Refresh一下工程;

再次启动项目后报错

java.lang.ClassNotFoundException: org.springframework.core.env.EnvironmentCapable

把spring-core-4.2.3.RELEASE.jar 拖到/WEB-INF/lib/目录下,Refresh一下工程;

再次启动项目后报错

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException:

 

Spring-MVC-所需要的jar包

标签:cto   prefix   lan   app   配置   life   网上   参考   opened   

原文地址:http://www.cnblogs.com/saber-himesama/p/7457620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!