在Struts2中,使用绑定select进行页面查询
来源:互联网 发布:c 加密解密算法 编辑:程序博客网 时间:2024/06/14 08:10
使用绑定数据的select框作为查询条件进行列表查询参考小例子
1 自定义下拉框Vo对象
publicclass GameNameSelectVO { private String id; //游戏名称ID private String gameName; //游戏名称 public String getId() { return id; } public voidsetId(String id) { this.id = id; } public String getGameName() { return gameName; } public voidsetGameName(String gameName) { this.gameName = gameName; }}
2 Action 作为查询控制器
privateList<GameNameSelectVO> gameNameList; //页面游戏名称下拉对象集合private String gameNameID; //游戏名称需要提供get set方法
方法
/** * 进入游戏参数查询页面 * @return */@SuppressWarnings("unchecked")public String toParameterPage(){//获得省份信息fundvo = gameInfoMonitorService.getProvinceInfo(String.valueOf(pid));if(null == gameNameID){gameNameID = "0";//初始查询全部}//获得游戏名称下拉数据集合gameNameList = gameInfoMonitorService.getGameNameSelectList();//得到每页记录数PropertyUtil p = new PropertyUtil();int pageSize = Integer.parseInt(p.getProperty("/system.properties", "account.alarm.pageSize"));// 获得查询记录总数int count = gameInfoMonitorService.getParameterListCount();// 根据总记录数、每页记录数、当前页码生成分页对象page = new Page<GameInfoPageVO>(count, pageSize, getCurrentPage());gameInfoVOList = gameInfoMonitorService.getParameterList(gameNameID,page.getCurrentPage(),page.getPageSize());return "parameterPage";}
3 Impl 实现类
/** * 获得游戏名称下拉集合 */ public List<GameNameSelectVO>getGameNameSelectList() { StringBuffer hql = new StringBuffer(); hql.append(" select rd.id,rd.game_name fromT_RCVD_GAME_DEFINITION rd " ); List<GameNameSelectVO> volist = new ArrayList<GameNameSelectVO>(); try{ List list = hibernateDao.queryBySql(hql.toString()); for(Iterator it =list.iterator();it.hasNext();){ Object [] objs = (Object[])it.next(); GameNameSelectVO vo = new GameNameSelectVO(); vo.setId(objs[0].toString()); vo.setGameName(objs[1].toString()); volist.add(vo); } }catch(Exception e){e.printStackTrace();} return volist; }
4 JSP页面
<div class="searchtime"> 游戏名称:<select name="gameNameID" id="" style="width: 10%;" > <option value="0">--全部--</option> <s:iterator value="gameNameList" var="gameNameVo"> <option value="<s:property value="id"/>" <c:if test="${gameNameVo.id eq gameNameID }" >selected</c:if> > <s:property value="gameName"/></option> </s:iterator> </select> <input type="submit" value="查询" class="button"/> </div>
0 0
- 在Struts2中,使用绑定select进行页面查询
- 在 SELECT 查询中使用子查询
- 在 SELECT 查询中使用 JOIN 联接
- 使用JavaScript在页面中进行跳转
- 在ADF中使用PrimaryKey进行查询
- 在ADF中使用AlternateKey进行查询
- 在页面中使用分页查询
- struts2中s:select标签在freemarker中的使用
- struts2 select绑定数据
- Struts2中<s:select>使用
- struts2中select的使用
- MySQL在字段中使用select子查询
- MySQL在字段中使用select子查询
- MySQL在字段中使用select子查询
- MySQL在字段中使用select子查询
- mybatis使用select语句进行关联查询
- 使用JQuery在Struts2中进行异步请求
- 如何在html静态页面中使用struts2标签
- 数据结构实验之排序八:快速排序 (sdut oj)
- How Redux works
- APP文件存储系统
- FPGA开发流程概述
- 老旧的钟表-水题
- 在Struts2中,使用绑定select进行页面查询
- angular2学习笔记(8)
- 数据库
- 114. Flatten Binary Tree to Linked List
- retrofit2和rxjava2一起使用时的rxjava.jar版本冲突问题解决
- ReactNative系列之十二图标组件react-native-vector-icons的使用
- java实现(2)-AVL树
- Ogre 获取显示鼠标位置
- 选择排序