Spring Web项目构建

108 阅读1分钟

1、创建一个web项目

2、添加依赖

  • Spring Web MVC项目引入下面两个包,其他的包会自动依赖
    • spring-context
    • spring-webmvc

3、添加serlet

  • 打开web.xml文件

4、创建resources目录设置为资源目录

5、创建web.xml->init-param配置的dispatcher-servlet.xml文件

6、定义视图解析器

7、创建文件夹

8、创建源码目录

9、设置为源码目录

10、创建HelloController.java

11、配置扫描包,开启注解驱动

12、配置Tomcat

13、加入项目

14、设置

15、启动项目 浏览器访问访问localhost:8080