package ajax.day03;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/demo")
public class DemoController {
/**
* @ResponseBody 自动将控制器方法返回值
* 自动处理: Java Bean/集合/数组, 转换为JSON
* 如果是 byte[] 则变成流传递到浏览器,
* 可以用于下载照片, 下载MP3 等..
*/
@RequestMapping("/hello.do")
@ResponseBody
public Object hello(String name){
System.out.println(name);
int[] ary = {1,2,3,4,5};
return ary;
}
@RequestMapping("/bean.do")
@ResponseBody
public Object beanDemo(){
return new Person(
1, "范传奇", "110", 0.5);
}
@RequestMapping("/array.do")
@ResponseBody
public Object arrayDemo(){
Person[] ary={
new Person(1,"范老师","110",0.5),
new Person(2,"小泽老师","110",0.5),
new Person(3,"王克晶","110",500)
};
return ary;
}
@RequestMapping("/map.do")
@ResponseBody
public Object mapDemo(){
Map<String, Object> map=
new HashMap<String, Object>();
map.put("id", 1);
map.put("name", "范老师");
map.put("mobile", "123");
map.put("salary", 1123.5);
return map;
}
@RequestMapping("/list.do")
@ResponseBody
public Object listDemo(){
List<Map<String, Object>> list=
new ArrayList<Map<String,Object>>();
Map<String, Object> map=
new HashMap<String, Object>();
map.put("id", 1);
map.put("name", "Tom");
map.put("mobile", "120");
list.add(map);
map = new HashMap<String, Object>();
map.put("id", 2);
map.put("name", "Jerry");
map.put("mobile", "110");
list.add(map);
return list;
}
/**
* 接收参数时候 参数名与AJAX发送端的key一致!
* @param name
* @param password
* @param mobile
* @param address
* @return
*/
@RequestMapping("/save.do")
@ResponseBody
public Object save(String name,
String password,
String mobile,
String address){
System.out.println(name);
System.out.println(password);
System.out.println(mobile);
System.out.println(address);
return true;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
JAVA个人博客系统源码.rar
共638个文件
svn-base:305个
png:76个
jpg:37个
需积分: 5 0 下载量 8 浏览量
2023-08-25
15:09:43
上传
评论
收藏 7.32MB RAR 举报
温馨提示
JAVA个人博客系统源码.rar
资源推荐
资源详情
资源评论
收起资源包目录
JAVA个人博客系统源码.rar (638个子文件)
all-wcprops 8KB
all-wcprops 3KB
all-wcprops 2KB
all-wcprops 2KB
all-wcprops 2KB
all-wcprops 2KB
all-wcprops 2KB
all-wcprops 2KB
all-wcprops 1KB
all-wcprops 953B
all-wcprops 943B
all-wcprops 830B
all-wcprops 631B
all-wcprops 615B
all-wcprops 453B
all-wcprops 439B
all-wcprops 439B
all-wcprops 427B
all-wcprops 425B
all-wcprops 310B
all-wcprops 280B
all-wcprops 278B
all-wcprops 266B
all-wcprops 266B
all-wcprops 127B
MyBatisTestCase.class 3KB
DemoController.class 3KB
User.class 2KB
Person.class 2KB
JsonResult.class 2KB
UserServiceImpl.class 1KB
UserController.class 1KB
PasswordException.class 1KB
NameException.class 1024B
UserService.class 316B
UserDao.class 236B
.classpath 2KB
.classpath 2KB
org.eclipse.wst.common.component 671B
org.eclipse.wst.common.component 665B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.container 49B
main.css 252KB
icon.css 241KB
umeditor.min.css 14KB
login.css 3KB
image.css 3KB
login_ghost.css 3KB
video.css 3KB
emotion.css 2KB
prettify.css 1KB
formula.css 869B
entries 8KB
entries 3KB
entries 3KB
entries 2KB
entries 2KB
entries 2KB
entries 2KB
entries 2KB
entries 1KB
entries 1KB
entries 1KB
entries 909B
entries 727B
entries 710B
entries 570B
entries 560B
entries 554B
entries 554B
entries 536B
entries 413B
entries 403B
entries 401B
entries 395B
entries 389B
entries 310B
fontawesome-webfont.eot 37KB
fontawesome-webfont.eot 37KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
wface.gif 49KB
jxface2.gif 40KB
yface.gif 28KB
bface.gif 27KB
tface.gif 19KB
fface.gif 18KB
cface.gif 8KB
08f8695d.select2-spinner.gif 2KB
0.gif 43B
day02.html 27KB
day03.html 13KB
edit.html 13KB
activity_detail.html 10KB
formula.html 7KB
map.html 6KB
activity.html 4KB
log_in.html 4KB
Change_password.html 4KB
ajax.html 2KB
共 638 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
谷雨之际
- 粉丝: 501
- 资源: 158
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功