
java SSm框架controller中 这两个方法有什么不同,为什么第一个页面接收不到数据,第二个反而可以?
/*@ResponseBody@RequestMapping("/getAllCates")Map<String,List<Category>>getAllCates(M...
/* @ResponseBody
@RequestMapping("/getAllCates")
Map<String, List<Category>> getAllCates(Map<String, List<Category>> m) throws Exception{
List<Category> allCates=categoryService.getAllCates();
System.out.println("查询到的所有分类为:************"+allCates);
m.put("cates", allCates);
return m;
}*/
@ResponseBody
@RequestMapping("/getAllCates")
public Map<String,List<Category>> getAllCates(){
List<Category> cates=categoryService.getAllCates();
Map<String,List<Category>> m=new HashMap<String,List<Category>>();
System.out.println("查到的分类列表为:********"+cates);
m.put("cates", cates);
return m;
} 展开
@RequestMapping("/getAllCates")
Map<String, List<Category>> getAllCates(Map<String, List<Category>> m) throws Exception{
List<Category> allCates=categoryService.getAllCates();
System.out.println("查询到的所有分类为:************"+allCates);
m.put("cates", allCates);
return m;
}*/
@ResponseBody
@RequestMapping("/getAllCates")
public Map<String,List<Category>> getAllCates(){
List<Category> cates=categoryService.getAllCates();
Map<String,List<Category>> m=new HashMap<String,List<Category>>();
System.out.println("查到的分类列表为:********"+cates);
m.put("cates", cates);
return m;
} 展开
2个回答
展开全部
参数是由前台页面传递过去的,控制层需要定义和前台传递的相同参数个数和名称,如果格式和类型及参数个数都相同的话调用到控制层方法的话参数也就获取到了,如果获取失败的话你还可以试试
String userName = request.getParameter("userName");
String password = request.getParameter("password");
这样的方式获取参数
String userName = request.getParameter("userName");
String password = request.getParameter("password");
这样的方式获取参数
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询