Spring RESTful之@ModelAttribute
@ModelAttribute
public SysUserMapping get(@RequestParam(required = false) String id) {
SysUserMapping entity = null;
if (StringUtils.isNotBlank(id)) {
entity = sysUserMappingService.get(id);
}
if (entity == null) {
entity = new SysUserMapping();
}
return entity;
} @RequestMapping(value = "form")
public String form(Model model) {
return "platform/usermapping/sysUserMappingForm";
}
对于form这个函数,即使什么也不做,此时你通过model.containsAttribute(“sysUserMapping”),你将会看到是存在值的。@ModelAttribute还有一个用途就是放在@RequestMapping的函数的参数前面,代表该参数和View绑定的对象做映射,当然前提是当初在获取页面的时候就要在页面中的Model中通过addAttribute进行添加。
Spring RESTful之@ModelAttribute的更多相关文章
- cxf spring restful 问题解决(jar包冲突)
SEVERE: Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error ...
- Spring MVC 中 @ModelAttribute 注解的妙用
Spring MVC 中 @ModelAttribute 注解的妙用 Spring MVC 提供的这种基于注释的编程模型,极大的简化了 web 应用的开发.其中 @Controller 和 @Rest ...
- 测试必须学spring RESTful Service(上)
文末我会说说为什么测试必须学spring. REST REST,是指REpresentational State Transfer,有个精辟的解释什么是RESTful, 看url就知道要什么 看met ...
- Spring MVC 对于@ModelAttribute 、@SessionAttributes 的详细处理流程
初学 Spring MVC , 感觉对于 @ModelAttribute 和 @SessionAttributes 是如何被Spring MVC处理的,这一流程不是很清楚, 经过Google资料,有了 ...
- Spring RESTFul Client – RestTemplate Example--转载
原文地址:http://howtodoinjava.com/2015/02/20/spring-restful-client-resttemplate-example/ After learning ...
- 002 Spring Restful案例
1:工程结构 需要注意的是需要额外导入以下三个包: jackson-annotations-2.6.1.jar jackson-core-2.6.1.jar jackson-databind-2.6. ...
- 采用CXF+spring+restful创建一个web接口项目
这篇文章是http://blog.csdn.net/zxnlmj/article/details/28880303下面,加入的基础上的restful特征 1.参加restful必jar包裹 jsr31 ...
- spring mvc:注解@ModelAttribute妙用
在Spring mvc中,注解@ModelAttribute是一个非常常用的注解,其功能主要在两方面: 运用在参数上,会将客户端传递过来的参数按名称注入到指定对象中,并且会将这个对象自动加入Model ...
- 实现Spring RESTful服务的SSL
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt386 本文介绍如何让基于Spring的REST服务变得SSL/TSL化. 首 ...
随机推荐
- bzoj1014: [JSOI2008]火星人prefix splay+hash+二分
Description 火星人最近研究了一种操作:求一个字串两个后缀的公共前缀.比方说,有这样一个字符串:madamimadam,我们将这个字符串的各个字符予以标号:序号: 1 2 3 4 5 6 7 ...
- 1-27 awk 基本使用
大纲: 色彩: awk基本使用 ##################################################### 一.色彩:shell中,设置输出文本色彩(前景色,背景色) ...
- hdu 4679 Terrorist’s destroy 树的直径+dp
题意:给你一棵树,每条边都有值W,然后问你去掉一条边,令val = w*max(两颗新树的直径),求val最小值~ 做法,先求树的直径,然后算出直径上每个点的最长枝条长度.这样对于每一条边,假如是枝条 ...
- Linux 策略路由配置
策略路由配置 #编辑rt_tables echo "192 net_192 " >> /etc/iproute2/rt_tables echo "196 ne ...
- ADO.NET简介
一.ADO.NET ADO.NET源起ADO(ActiveX Data Objects),是一个COM组件库,在NET编程环境中优先使用的数据访问接口, 提供对诸如 SQL Server 和 XML ...
- SQL server 数据库用户表名称
转自(http://blog.163.com/jlj_sk/blog/static/22579293200861422833924/) 取得SQL server 数据库中 所有用户表名称 select ...
- 多进程回声服务器/客户端【linux】
并发服务器端 #include <unistd.h> #include <stdio.h> #include <sys/wait.h> #include <c ...
- Sumlime text3 安装包、汉化包、注册码
Sumlime text3 安装包.汉化包.注册码 http://files.cnblogs.com/files/panmy/%E5%9C%86%E8%A7%92.rar
- vector概念
body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...
- shell getopts学习
#!/bin/bash while getopts i:vh name do case $name in i) opt=1 echo $OPTARG;; v) opt=2 echo 2;; h) op ...