黑马程序员技术交流社区

标题: 学习笔记 [打印本页]

作者: nous    时间: 2019-6-12 13:56
标题: 学习笔记
1.导包要看导自己的还是Spring的...... 例如监听器



2.Spring注入Bean两种方法:

第一种:

创建Bean:                                                           依赖注入:

- @component - 所有                                    @Autowired :@Qualifier一起使用。
- @service         -service              +                @Resource(name="beaname")
- @contoller       -sevlet                                     根据名字去注入
- @Repository   -dao                                     @Value 注入普通属性

第二种:

applicationContext.xml配置文件

有参方法或者set方法



3.//设置模型
modelAndView.addObject("roleList",roleList);
设置的"roleList",与前端的jsp展示的数据并且遍历<c:forEach items="${roleList}" var="role">关联.    var="role"的var找的是

//设置视图
modelAndView.setViewName("role-list");  
模型的"roleList"只能在这指定的视图"role-list"的jsp里找到。



4.User类是通过Dao层  封装
jdbcTemplate.query("select * from sys_role", new BeanPropertyRowMapper<User>(User.class));


5.注入Bean时
<property name="userDao" ref="userDao">   ref指的是下面的id
bean id="userDao" class="com.itheima.dao.impl.UserDaoImpl">




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2