eclipse搭建SpringMvc web项目

2024-10-13 05:06:22

1、新建web项目

eclipse搭建SpringMvc web项目

2、配置选择如下

eclipse搭建SpringMvc web项目

3、引入相关spring的jar包

eclipse搭建SpringMvc web项目

4、新增spring-mvx.xml配置文件

eclipse搭建SpringMvc web项目

5、配置文件代码如下

eclipse搭建SpringMvc web项目

6、在web.xml配置文件中新增如下代码,我们用spring来管理所有.do的访问链接

eclipse搭建SpringMvc web项目

7、新建一个普通java类

eclipse搭建SpringMvc web项目

8、类中代码如下@觊皱筠桡Controller - 标识为spring的控制器@RequestMapping("/helloWorld媪青怍牙") - 定义访问路径为 /helloWorld.domodel.addAttribute("message", "StringMvc环境搭建!"); 试图定义参数messagereturn "helloWorld"; 即返回helloWorld.jsp

eclipse搭建SpringMvc web项目

9、新建返回页面

eclipse搭建SpringMvc web项目

10、代码如下, 把控制器当中的参数输出

eclipse搭建SpringMvc web项目

11、新建工程首页

eclipse搭建SpringMvc web项目

12、页面内放置访问链接

eclipse搭建SpringMvc web项目

13、访问工程

eclipse搭建SpringMvc web项目

14、正常返回结果

eclipse搭建SpringMvc web项目

15、以上,是一个最简单的spring Mvc web项目,后续可进行扩展

猜你喜欢