eclipse搭建SpringMvc web项目

2025-04-22 15:35:16

1、1.新建web项目

eclipse搭建SpringMvc web项目

2、2.配置选择如下

eclipse搭建SpringMvc web项目

3、3.引入相关spring的jar包

eclipse搭建SpringMvc web项目

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

eclipse搭建SpringMvc web项目

5、5.配置文件代码如下

eclipse搭建SpringMvc web项目

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

eclipse搭建SpringMvc web项目

7、7.新建一个普通java类

eclipse搭建SpringMvc web项目

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

eclipse搭建SpringMvc web项目

9、9.新建返回页面

eclipse搭建SpringMvc web项目

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

eclipse搭建SpringMvc web项目

11、11.新建工程首页

eclipse搭建SpringMvc web项目

12、12.页面内放置访问链接

eclipse搭建SpringMvc web项目

13、13.访问工程

eclipse搭建SpringMvc web项目

14、14.正常返回结果

eclipse搭建SpringMvc web项目

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

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢