1、绑定基本数据类型
在Controller类中添加业务方法:
/**
* 绑定基本数据类型
*/
@RequestMapping("/baseType")
@ResponseBody
public String baseType(@RequestParam("id") int id){
return "id="+id;
访问:
2、绑定包装类
Controller类中的业务方法:
/**
* 绑定包装类
*/
@RequestMapping("/packageType")
@ResponseBody
public String packageType(@RequestParam("id") Integer id){
return "id:"+id;
}
访问:
3、绑定数组类型
Controller类中的业务方法:
/**
* 绑定数组
*/
@RequestMapping("/arrayType")
@ResponseBody
public String arrayType(String[] name){
StringBuffer stringBuffer = new StringBuffer();
for (String item:name){
stringBuffer.append(item+" ");
}
return stringBuffer.toString();
}
访问: