springMVC传递对象参数
初学java,由于项目紧急,来不及仔细的研究,在传递参数时就老老实实的一个一个的采用@RequestParam注解方式传递,最近认真看了一下,发现java也具有类似Asp.net Mvc传递对象做参数的方式,即采用@ModelAttribute注解的方式,接收方式如下:
@RequestMapping("hello")
public String Hello(@ModelAttribute("user") User user)
{
System.out.println(user.getUserName());
return "hello";
}
User类如下:
public class User {
private int userID;
private String userName;
public int getUserID() {
return userID;
}
public void setUserID(int userID) {
this.userID = userID;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
访问方式发现和采用逐个的参数传递时也没有什么不同,在我本地的地址如下:
/test/hello?userID=12&userName=sdfsd
springMVC传递对象参数的更多相关文章
- 关于springMVC 传递 对象参数的问题
1.前端请求必须是 post 2.前端数据data必须做 json字符串处理 JSON.stringify(data) 3. contentType: 'application/json', 4.@ ...
- PHP通过传递对象参数调用asp.net Webservice 服务
asp.net 测试服务 ProcessRequest.asmx文件代码 public class ProcessRequest : System.Web.Services.WebService ...
- jQuery 传递对象参数到Spring Controller
当jQuery 发送ajax请求需要传递多个参数时,如果参数过多,Controller接收参数时就需要定义多个参数,这样接口方法会比较长,也不方便.Spring可以传递对象参数,将你需要的所有查询条件 ...
- JavaScript onclick传递对象参数(easyui传递一行数据时)错误:uncaught SyntaxError: Unexpected identifier
JavaScript onclick传递对象参数(easyui传递一行数据时)错误:uncaught SyntaxError: Unexpected identifier 博主遇到的是用onclick ...
- springmvc 传递对象数组参数 property path is neither an array nor a List nor a Map
Spring MVC 3: Property referenced in indexed property path is neither an array nor a List nor a Map ...
- springMVC传对象参数、返回JSON格式数据
假如请求路径:http://localhost/test/test.do?user.id=1 后台接收参数的方法如下: @RequestMapping("/test") publi ...
- jquery中ajax向action传递对象参数,json ,spring注入对象
首先,我这个程序的框架是spring+struts2+hibernate. 后端的action的需要接受从前端传进来的参数,由spring的注入,可知,如果前端用的是form的话,只需要在每个inpu ...
- Spring MVC中如何传递对象参数
springController: @Controller @RequestMapping("/user") public UserController extends BaseC ...
- springMVC传对象参数
springController: [java] view plaincopy @Controller @RequestMapping("/user") public UserCo ...
随机推荐
- ASCII 码对照表
ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 0 NUT 32 (space) 64 @ 96 . 1 SOH 33 ! 65 A 97 a 2 ST ...
- 性能测试之Jforum平台的搭建
学习Jmeter性能基础,想要借助1款现有的软件平台,来练习jmeter基础,<Jmeter实战>书籍上给出样例软件平台:Jforum 一.环境准备 准备:tomcat9.mysql5.5 ...
- jQuery(Dom节点操作)
- webuploader 教程
1.引入js和css <!-- Web Uploader --> <link rel="stylesheet" type="text/css" ...
- HDU 3292
快速幂模+佩尔方程 #include <iostream> #include <cstdio> #include <algorithm> #include < ...
- NOIP2012 同余方程 题解
描写叙述 求关于x的同余方程ax ≡ 1 (mod b)的最小正整数解. 格式 输入格式 输入仅仅有一行,包括两个正整数a, b,用一个空格隔开. 输出格式 输出仅仅有一行,包括一个正整数x0.即最小 ...
- UVALive 3027 Corporative Network 带权并查集
Corporative Network A very big corporation is developing its corporative networ ...
- 【DataStructure】The difference among methods addAll(),retainAll() and removeAll()
In the Java collection framework, there are three similar methods, addAll(),retainAll() and removeAl ...
- CentOS 7 安装 vmware tools 提示The path "" is not a valid path to the 3.10.0-957.el7.x86_64 kernel headers.
输入“mkdir /mnt/cdrom”在/mnt目录下新建一个名为cdrom的文件夹 mkdir /mnt/cdrom 输入“mount -t iso9660 /dev/cdrom /mnt/cdr ...
- c++面向对象程序设计 谭浩强 第一章答案
c++面向对象程序设计 谭浩强 答案 第一章 目录: c++面向对象程序设计 谭浩强 答案 第一章 c++面向对象程序设计 谭浩强 答案 第二章 c++面向对象程序设计 谭浩强 答案 第三章 c++面 ...