@[toc]角色
角色管理
角色查询
在aside.jsp点击/系统管理/角色管理发出/role.findAll.do
RoleController
@RequestMapping("/findAll.do")
public ModelAndView findAll() throws Exception {
ModelAndView mv = new ModelAndView();
List<Role> roleList = roleService.findAll();
mv.addObject("roleList", roleList);
mv.setViewName("role-list");
return mv;
}
IRoleService
public interface IRoleService {
public List<Role> findAll() throws Exception;
void save(Role role) throws Exception;
}
RoleServiceImpl
@Override
public List<Role> findAll() throws Exception{
return roleDao.findAll();
IRoleDao
@Select("select * from role")
List<Role> findAll() throws Exception;
role-list.jsp
将role-list.jsp放入/pages
角色添加
在role-list.jsp上点击新建按钮,跳转到role-add.jsp封装信息后 发请求做save操作,注意完成插入操作后在controller中要重定向到findAll.do
RoleController
@RequestMapping("/save.do")
public String save(Role role) throws Exception {
roleService.save(role);
return "redirect:findAll.do";
}
IRoleService
void save(Role role) throws Exception;
@Override
public void save(Role role) {
roleDao.save(role);
}
IRoleDao
@Insert("insert into role(roleName,roleDesc) values(#{roleName},#{roleDesc})")
void save(Role role);
页面
role-add.jsp