package com.ljl.controller;
@Controller
public class TestController {
@RequestMapping(value="baseType.do",method=RequestMethod.GET)
@ResponseBody //返回值会放到responsebody数据区里
public String baseType(@RequestParam(value="xage") int age) { //int 的值是不能为null的
return "age:"+age;
}
}
包装类型
package com.ljl.controller;
@Controller
public class TestController {
@RequestMapping(value="baseType.do",method=RequestMethod.GET)
@ResponseBody //返回值会放到responsebody数据区里
public String baseType(Integer age) { //age不传值,默认为null
return "age:"+age;
}
}
数组
package com.ljl.controller;
@Controller
public class TestController {
@RequestMapping(value="array.do")
@ResponseBody //返回值会放到responsebody数据区里
public String array(String[] name) {
StringBuilder sbf=new StringBuilder();
for(String item:name) {
sbf.append(item).append("");
}
return sbf.toString();
}
}