一、学习资源
Java EE企业级应用开发教程(Spring+Spring MVC+MyBatis)(第2版)
二、基础源码
Spring MVC常用参数
Spring MVC简单应用
Spring MVC参数绑定
三、实验结果
3.1 Spring MVC常用参数
本实验采用的是本地安装的tomcat8.5.0版本
(1)创建maven 管理的java web工程
(2)添加本地tomcat
war包
(3)实验过程
输出Hello Word
访问端口:http://localhost:8080/chapter11/controller01
Spring MVC 常用注解
@Controller和@RequestMapping
实现自动寻找controller
访问端口:http://localhost:8080/chapter11/execute
@RequestMapping
访问端口: http://localhost:8080/chapter11/toWelcome
@RequestParam
访问端口: http://localhost:8080/chapter11/toLogin
@PathVariable
访问端口: http://localhost:8080/chapter11/claList/1/stuList/2
访问端口: http://localhost:8080/chapter11/claList/3/stuList/4
@Cookie Value
访问端口: http://localhost:8080/chapter11/testCookie
@RequestHeader
访问端口: http://localhost:8080/chapter11/testRequestHeader
3.2 Spring MVC参数绑定
本实验使用的为tomcat7.0版本
在源码文件的pom.xml中有配置插件
3.2.1 简单数据类型绑定
默认数据类型
访问端口:http://localhost:8080/findById
简单数据类型
绑定POJO类型
自定义数据类型
3.2.2 复杂数据类型绑定
(知道一点),此处前端值向后端传递没有成功
数组类型
集合类型
四、实验小结
本实验需要熟练使用maven和Tomcat,以及理解spring MVC参数使用;设计javaweb知识,需要回顾前后端值传递过程。文章来源:https://www.toymoban.com/news/detail-441454.html
欢迎大家在评论区讨论交流,有时间就回。。。。
看到这里记得点赞+关注^^文章来源地址https://www.toymoban.com/news/detail-441454.html
到了这里,关于Spring MVC:常用参数(注解)的使用和参数绑定的验证的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!