1. 在IDEA中创建一个空白工程,在空白工程新建maven父工程,父工程中创建子工程:
maven父子工程的创建:地址
maven添加依赖:地址
两种类型:
qucikstart:
- model:javabean
- service:业务逻辑
- dao:数据库管理
webapp:
- manager:controller
- api:接口
2. manager:配置springMVC
- pom.xml中配置spring/springmvc依赖
- 创建springmvc配置文件:springMVC.xml(扫描controller注解、注解映射器和注解适配器、视图解析器 )
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-5.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-5.1.xsd ">
<!-- 扫描controller注解,多个包中间使用半角逗号分隔 -->
<context:component-scan base-package="com.moke.edu.web.controller"/>
<!--注解映射器、注解适配器 -->
<mvc:annotation-driven></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/jsp/" />
<property name="suffix" value=".jsp" />
</bean>