1.Controller
@Controller
@RequestMapping(value="/user")
public class UserController extends BaseController {
String menuUrl = "user/listUsers.do"; //菜单地址(权限用)
@Resource(name="userService")
private UserService userService;
@Resource(name="roleService")
private RoleService roleService;
@Resource(name="menuService")
private MenuService menuService;
/**
* 显示用户列表(用户组)
*/
@RequestMapping(value="/listUsers")
public ModelAndView listUsers(Page page)throws Exception{
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
String USERNAME = pd.getString("USERNAME");
if(null != USERNAME && !"".equals(USERNAME)){
USERNAME = USERNAME.trim();
pd.put("USERNAME", USERNAME);
}
String lastLoginStart = pd.getString("lastLoginStart");
String lastLoginEnd = pd.getString("lastLoginEnd");
if(lastLoginStart != null && !"".equals(lastLoginStart)){
lastLoginStart = lastLoginStart+" 00:00:00";
pd.put("lastLoginStart", lastLoginStart);
}
if(lastLoginEnd != null && !"".equals(lastLoginEnd)){
lastLoginEnd = lastLoginEnd+" 00:00:00";
pd.put("lastLoginEnd", lastLoginEnd);
}
page.setPd(pd);
List<PageData> userList = userService.listPdPageUser(page); //列出用户列表
List<Role> roleList = roleService.listAllERRoles(); //列出所有二级角色
mv.setViewName("system/user/user_list");
mv.addObject("userList", userList);
mv.addObject("roleList", roleList);
mv.addObject("pd", pd);
mv.addObject(Const.SESSION_QX,this.getHC()); //按钮权限
return mv;
}
}
2.user_list.jsp
<select class="chzn-select" name="ROLE_ID" id="role_id" data-placeholder="请选择职位" style="vertical-align:top;width: 120px;">
<option value=""></option>
<option value="">全部</option>
<c:forEach items="${roleList}" var="role">
<option value="${role.ROLE_ID }" <c:if test="${pd.ROLE_ID==role.ROLE_ID}">selected</c:if>>
${role.ROLE_NAME }
</option>
</c:forEach>
</select>
JSTL应用----下拉列表
最新推荐文章于 2020-07-24 11:34:58 发布