1.手动配置时,容易导入错误的类。正确配置如下:
2.model、mdelAndView的对象填充数据的方式容易混淆
ModelAndView:
ModelAndView model = new ModelAndView();
model.addObject(“itemsList”,itemsList);
model.setViewName(“itemsList”);
Model:
model.addAttribute(“itemsList”, itemsList);
return “itemsList”;
return model;
3.组合类中,注入的items对象未是一个bean
autowire field: springmvc.Items springmvc.ArrayClass.items; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [springmvc.Items] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
4.错误的认为每一个类都要注解成bean,在jsp与后台交互的过程中,实体类与组合类不用注解成bean,一旦注解成bean,比较难将页面传递过来的值赋给属性。
5.传递过来的参数值为null或者“”时,参数类型是基本数据类型导致出现异常。
6.参数类型是float时,未正确在数据末尾添加f/F导致数据添加出错