spring MVC中关于model.addAttribute的使用方法【翻译】

2023-05-16

关于model.addAttribute的使用方法

http://krams915.blogspot.com/2010/12/spring-3-mvc-using-modelattribute-in.html  (可能要 break the wall)

好像还有点难度的样子,先看懂这篇:

http://wenku.baidu.com/link?url=9PZuIW4KSl3_quLVmLs-rTjYJsHh3e35E6Nn5lJlNp3crol5bdKVeeaywiFt9Ub_XYW8UPM5CKrpvhK4Isc3QUhdYmt1q8rUHR_MhnR2VqG


http://blog.csdn.net/li_xiao_ming/article/details/8349115 这篇不是很清晰


简要翻译一下:(学习笔记,只保留要点)


【什么是ModelAttribute - MA】
MA在controller中的2个应用场景:


1. 放在 方法的参数中, MA映射了一个分配在特定的,方法参数中 的model.
---这就是控制器得到一个参考,找到object,获取从表单带来存在object里的值。
e.g.(see the processSubmit() method below)


2. 放在方法里,为model提供参考数据,
方法签名可以 包含同样的types,正如@RequestMapping(RM) annotation中预先声明的一样。
(see the populatePetTypes() method in the following example)


注意MA是在RM标记的处理方法之前执行。


要把objects暴露给jsp页面,@MA是个方便的东东。把object返回回controller也是方便。


【启用 Spring MVC,配3个xml文件】
To enable Spring MVC we need to add it in the web.xml


--web.xml
Take note of the URL pattern. When accessing any pages in our MVC application, the host name must be appended with


--spring-servlet.xml
This XML config declares a view resolver. All references to a JSP name in the controllers will map to a corresponding JSP in the /WEB-INF/jsp location.


--applicationContext.xml
By convention, we must declare an applicationContext.xml
applicationContext.xml
This XML config declares three beans to activate the Spring 3 MVC programming model.




本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

spring MVC中关于model.addAttribute的使用方法【翻译】 的相关文章

随机推荐

  • 3.4日期处理

    include lt iostream gt include lt cstdio gt 平年和闰年的每月的天数 int month 13 2 61 0 0 31 31 28 29 31 31 30 30 31 31 30 30 31 31
  • 关于STL和Boost的理解

    xff11 xff0e STL STL是standard Template Library即标准模板库的英文缩写 xff0c 是惠普实验室开发的一系列软件的统称 从根本上讲 STL是一些 容器 的集合 xff0c 这些容器有list vec
  • Ubuntu 各版本号和名称对照

    版本开发代号中译发布日期支持结束时间内核版本桌面版服务器版4 10Warty Warthog多疣的疣猪2004 10 202006 04 302 6 85 04Hoary Hedgehog白发的刺猬2005 04 082006 10 312
  • 【无标题】安装ROS E: 无法定位软件包 ros-melodic-desktop-full

    一 遇到问题 二 可能的原因和解决方法 1 源换一下 xff1a xff08 1 xff09 我是看这位大佬的 5条消息 记录 解决Ubuntu安装ros报错E Unable to locate package ros kinetic de
  • 无线通信原理及协议栈(ZigBee、蓝牙等)解析

    1 天线 说起无线电通信 xff0c 不可不提起天线 在无线电设备中 xff0c 用来辐射和接收无线电波的装置称为天线 在发射端 xff0c 发射机产生的已调制的高频振荡电流 xff08 能量 xff09 经馈电 xff08 指被控制装置向
  • 串口Serial连接方式

    串口Serial连接方式 1 协议终端选择Serial 2 会话选项 xff0c 选择 串行 3 进入电脑 设备管理器 xff0c 查看USB Serial Port以及端口设置 串行选项根据端口设置配置 确定并连接即可
  • tcp/ip 协议栈实现2-socket文件系统

    core initcall sock init net socket c static int init sock init void int err Initialize sock SLAB cache sk init Initializ
  • VMware虚拟机安装Windows11(无需设置TPM密码)

    VMware虚拟机安装Windows11 xff08 无需设置TPM密码 xff09 注意 xff1a 需要新版VMware xff0c 目前小白的版本为 16 2 3 一 新建虚拟机向导 1 新建虚拟机 点击菜单栏文件 新建虚拟机 2 配
  • ROS相关:使用rospy 编写ros程序并使用rosbag存储数据

    为什么使用rospy ROS支持C 43 43 和Python xff0c 由于ROS的底层是由C 43 43 编写 xff0c 因此大多数的ROS程序都使用C 43 43 xff0c 但是Python语言接口简单 xff0c 更容易编写
  • C函数调用过程

    这几天在看GCC Inline Assembly xff0c 在C代码中通过asm或 asm 嵌入一些汇编代码 xff0c 如进行系统调用 xff0c 使用寄存器以提高性能能 xff0c 需要对函数调用过程中的堆栈帧 xff08 Stack
  • 【GitHub】Branches和Tags分别是做什么用的?

    在 GitHub 中 xff0c Branches xff08 分支 xff09 和 Tags xff08 标签 xff09 都是用于版本控制的重要工具 Branches xff08 分支 xff09 可以用来创建一个新的开发分支 xff0
  • git clone 指定分支

    我们在有一个工程的权限后 xff0c 按照常规操作去拉代码 xff0c 往往会拉到默认的master分支 若我们担心master分支拉下来后 xff0c 与其他代码有冲突 xff0c 想直接拉某分支的代码 xff0c 则该怎么操作呢 1 我
  • rocketmq的消息msgId和offsetMsgId

    1 rocketmq的消息发送时 xff0c producer客户端 生成msgId xff08 通过 ip 43 进程 43 自增值 43 当前与系统启动时间差值 xff09 xff0c 有另外的一个叫法uniqId 方法入口 xff1a
  • 算法 - 桶排序(Bucket Sort)

    执行流程 xff1a 创建一定数量的桶 xff08 比如用数组 链表作为桶 xff09 按照一定的规制 xff08 不同类型的数据 xff0c 规则不同 xff09 xff0c 将序列中的元素均匀分配到对应的桶分别对每个桶进行单独排序将所有
  • 测试Pangolin是否安装成功

    一 终端输入 cd Pangolin examples HelloPangolin cmake make HelloPangolin 二 显示这个结果则成功 三 顺便放一个 我可终于装完了ORB SLAM3 被内存不够折腾了好久 换个内存条
  • 交叉编译工具 aarch64-linux-gnu-gcc 的介绍与安装

    AArch64 是随 ARMv8 ISA 一起引入的 64 位架构 xff0c 用于执行 A64 指令的计算机 而且在 AArch64 状态下执行的代码只能使用 A64 指令集 xff0c 而不能执行 A32 或 T32 指令 但是 xff
  • 02 机器学习中的评估指标

    机器学习中的评估指标 1 机器学习的目标 根本目标 xff1a 在给定的训练数据上 xff0c 试图训练出能够归纳数据的规律的模型 xff0c 并且能在未知样本上也有好的效果 泛化能力强的模型最好 能很好地适用于未知样本 xff0c 如错误
  • 方便Git提交代码的几个工具

    团队使用git管理代码 xff0c 为了提交方便 xff0c 查看Log方便 xff0c 师傅告诉我先安装几个工具 xff0c 如下 xff1a cola gitk AnyEdit 一 gitk安装 xff08 备注 xff1a 开始我没走
  • git提交 本地分支和远程分支断开连接

    1级标题 当 git push origin branch name时遇到报错如下 xff1a fatal origin does not appear to be a git repository fatal Could not read
  • spring MVC中关于model.addAttribute的使用方法【翻译】

    关于model addAttribute的使用方法 http krams915 blogspot com 2010 12 spring 3 mvc using modelattribute in html 可能要 break the wal