关于spring-mvc:SpringMVC框架搭建过程

41次阅读

共计 1428 个字符,预计需要花费 4 分钟才能阅读完成。

一 创立 maven 工程,选中 webapp,批改项名

二 补全目录构造

三 导入依赖

1. 批改版本号
<properties> 
 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>
</properties>
2. 版本锁定
<properties>
 <spring.version>5.0.2.RELEASE</spring.version>
</properties>
3. 导入依赖
<dependencies>
 <dependency> <groupId>org.springframework</groupId>
 <artifactId>spring-context</artifactId>
 <version>${spring.version}</version>
 </dependency>
 <dependency> <groupId>org.springframework</groupId>
 <artifactId>spring-web</artifactId>
 <version>${spring.version}</version>
 </dependency>
 <dependency> <groupId>org.springframework</groupId>
 <artifactId>spring-webmvc</artifactId>
 <version>${spring.version}</version>
 </dependency>
 <dependency> <groupId>javax.servlet</groupId>
 <artifactId>servlet-api</artifactId>
 <version>2.5</version>
 <scope>provided</scope>
 </dependency>
 <dependency> <groupId>javax.servlet.jsp</groupId>
 <artifactId>jsp-api</artifactId>
 <version>2.0</version>
 <scope>provided</scope>
 </dependency></dependencies>

四 创立 ContextConfiguration.xml

五 配置 web.xml

<servlet>
 <servlet-name>dispatcherServlet</servlet-name>
 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <init-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>classpath:ContextConfiguration.xml</param-value>
 </init-param></servlet>
<servlet-mapping>
 <servlet-name>dispatcherServlet</servlet-name>
 <url-pattern>/</url-pattern>
</servlet-mapping>

六 创立 Collector 类
七 配置 ContextConfiguration.xml

正文完
 0