displaytag如何实现获取到每行的id字段的值。
1、displaytag如何实现获取到每行的id字段的值。
使用封装好的框架,有时候,对于一个知识点不熟悉,可能会浪费你大把的时间,我使用displaytag主要是使用它的分页技术,但是客户提出的需求,是获取到每行的id,然后选择一个用户名称(用户id),将他们关联操作,其实业务很简单,但是获取到你想要的这一行,一开始确实难为着我了,后来才发现,很简单。
代码如下所示:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>
<%
//获取绝对路径路径
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath %>" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>图书管理-图书查询</title>
<link href="resource/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="resource/table/bootstrap-table.min.css">
<link type="text/css" rel="stylesheet" href="resource/select2/css/select2.min.css">
<script type="text/javascript" src="resource/js/jquery.min.js"></script>
<script type="text/javascript" src="resource/js/bootstrap.min.js"></script>
<script src="resource/table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="resource/select2/js/select2.js"></script> <style type="text/css"> tr th{text-align:center;}
tr td{text-align:center;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#clickIt").click(function(){
alert("sorry,此类图书数量为0,不可借阅......");
});
}); //启动之前,先查询出地方前置库信息,然后将地方前置库的信息传递到实例数据表中
$(function(){
var url = "system/book/userAjax";
$.ajax({
type : 'POST',
url : url,
dataType : 'json',
//traditional : true,
//async : false,
success : function(data) {
//console.log(data.list);
var result = data.list;
for(var i=;i<result.length;i++){
//console.log(result[i].userAccount);
$("#userNameCategory").append("<option value='"+ result[i].userId +"'>" + result[i].userAccount + "</option>");
}
}
})
}); function borrowBooksFunction(bookIds){
//关键点在于获取到图书的编号
console.log(bookIds);
//关键点,管理员通过借阅这本书给学生,将这本书的bookId给某个学生
$("#setBookId").val(bookIds);
} </script>
</head>
<body>
<div>
<ul class="breadcrumb" style="margin: 0px;">
<li>系统管理</li>
<li>图书管理</li>
<li>图书查询</li>
</ul>
</div>
<form action="${basePath }system/book/select" method="post" class="form-inline">
<div class="row alert alert-info" style="margin: 0px; padding: 5px;">
<div class="form-group">
<label>条件:</label>
<select name="condition" class="form-control">
<option value="bookName" ${condition == 'bookName'?'selected':'' }>图书名称</option>
<option value="bookAuthor" ${condition == 'bookAuthor'?'selected':'' }>图书作者</option>
<option value="bookType" ${condition == 'bookType'?'selected':'' }>图书类别</option>
</select>
<input type="text" name="content" value="${result }" class="form-control" placeholder="请输入查询条件" />
</div>
<input type="submit" class="btn btn-danger" value="查询">
<a href="system/book/insert" class="btn btn-success">
添加图书
</a>
</div>
<div class="row" style="padding: 15px;">
<display:table name="${list }" id="bookIds" pagesize="" requestURI="system/book/select" class="table table-hover table-striped table-bordered">
<display:column property="bookId" title="图书编号"></display:column>
<display:column property="bookName" title="图书名称"></display:column>
<display:column property="bookAuthor" title="图书作者"></display:column>
<display:column property="bookPrice" title="图书价格"></display:column>
<display:column property="bookType" title="图书类型"></display:column>
<display:column property="bookPublish" title="图书出版社"></display:column>
<display:column property="bookSum" title="图书总数"></display:column>
<!-- 如果是管理员,具有借书,还书,修改,删除功能的权限 -->
<c:if test="${userMark == '管理员' }">
<display:column paramId="bookId" paramProperty="bookId" title="借书">
<!-- 按钮触发模态框 -->
<a href="" id="borrowBooks" onclick="borrowBooksFunction(<c:out value='${bookIds.bookId}'></c:out>)" data-toggle="modal" data-target="#myModal"> 借书
</a>
</display:column>
<display:column href="system/book/update" paramId="bookId" paramProperty="bookId" title="修改" value="修改"></display:column>
<display:column href="system/book/delete" paramId="bookId" paramProperty="bookId" title="删除" value="删除"></display:column>
</c:if> </display:table>
</div>
</form> <form action="${basePath }system/book/adminBorrow" method="post" class="form-horizontal setWidth">
<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">
用户信息
</h4>
</div>
<div class="modal-body">
<input type="hidden" name="bookId" id="setBookId" value=""/>
<select class="form-control width175" id="userNameCategory" name="userId">
<option value=''>-- 请选择 --</option>
</select>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<!-- <button type="button" class="btn btn-primary">
提交
</button> -->
<input type="submit" class="btn btn-success" value="提交" />
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
</form> </body>
</html>
效果如下所示:

2、关键点操作如下所示:

然后如下所示:

然后完成你想要实现的效果:

打完收工
待续......
displaytag如何实现获取到每行的id字段的值。的更多相关文章
- 如何在dapper中获取刚插入行的ID
二话不说: 1.先建立个表 CREATE TABLE [dbo].[UserInfo]( [ID] [int] IDENTITY(1,1) NOT NULL, [UserName] [nc ...
- Jmeter获取数据库查询结果某一字段的值
1.首先进行连接数据库 2.添加JDBC Request 3.添加BeanShell PostProcessor 4.注意点:如果获取的是INT数字类型的,结尾需要添加toString()
- SQL Server 动态行转列(参数化表名、分组列、行转列字段、字段值)
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 实现代码(SQL Codes) 方法一:使用拼接SQL,静态列字段: 方法二:使用拼接SQL, ...
- SharePoint 获取Lookup 字段的值
获取某个List里的Lookup字段的值是很普遍的事,那么我们将它封装起来 获取Lookup字段值的方法: /// <summary> /// To get lookup field Id ...
- android获取textview的行数
最近项目需求,需要获取Textview的行数,通过行数与TextView的maxLines进行比较来确定是否显示TextView下方的展开按钮是否显示,废话少说直接上代码,mTextView.getL ...
- StringGrid 实例2:1、获取 StringGrid 的行数、列数; 2、给单元赋值.
实例2: 本例功能: 1.获取 StringGrid 的行数.列数; 2.给单元赋值. 运行效果图:
- js日期的写法,获取girdviw的行数、提示信息、验证数量信息
//制订日期(js日期的写法) var myDate = new Date(); var theDate = myDate.toLocaleDateString(); //获取今天的日期 //获取控 ...
- jquery easyui datagrid 获取Checked选择行(勾选行)数据
原文:jquery easyui datagrid 获取Checked选择行(勾选行)数据 getSelected:取得第一个选中行数据,如果没有选中行,则返回 null,否则返回记录. getSel ...
- sql 语句 获取某张表某列字段最短的某几行数据
sql 语句 获取某张表某列字段最短的某几行数据 SELECT C_name,C_code FROM Catalog where LEN(C_code)=LEN((SELECT top 1 C_cod ...
随机推荐
- vue(初探预渲染)
---恢复内容开始--- 一.前言 1.简介预渲染 2.案例演示(不配置预渲染) 3.配置预渲染, 二.主要内容 1.简 ...
- python10--函数的来源,优点,定义,组成,使用(定义,调用)函数的分类,函数的返回值
一.函数 # *****# 函数:完成 特定 功能的代码块,作为一个整体,对其进行特定的命名,该名字就代表函数# -- 现实中:很多问题要通过一些工具进行处理 => 可以将工具提前生产出 ...
- Money King【题解】
我又傻了……竟然忘了区别大根堆和小根堆的性质,以至于一个符号打错,debug了半天……(我真是太菜了……) 题目描述 Once in a forest, there lived N aggressiv ...
- jmeter和loadrunner关于分布式部署测试计划的优缺点
1.都可以实现分布式负载,相对来说loadrunner更强大一些 2.都支持在windows和linux环境的负载生成器,控制台方面,jmeter跨平台,而loadrunner不是 3.loadrun ...
- Springboot自定义异常处理
1.自定义异常类 import lombok.Data; @Data public class UserException extends RuntimeException { private Lon ...
- [译]Async/Await - Best Practices in Asynchronous Programming
原文 避免async void async void异步方法只有一个目的:使得event handler异步可行,也就是说async void只能用于event handler. async void ...
- JavaScript的Document ,Histroy,Location对象
1. Document对象: a) 属性: 名称 描述 alinkColor 设置或检索文档中所有活动链接的颜色 bgColor 设置或检索 Document 对象的背景色 body ...
- springboot 共享session
1.pom添加jar依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifact ...
- 记一次Java动态代理实践【首发自高可用架构公众号】
1. 背景 最近在做数据库(MySQL)方面的升级改造.现状是数据库同时被多个应用直连,存在了一些问题: 有大量的重复代码,维护成本较高,也不优雅: 出现SQL语句质量的问题无法很快定位到是哪个应用导 ...
- 转 原生js canvas实现苹果电脑mac OS窗口最小化效果
http://www.17sucai.com/pins/demo-show?id=2459 http://www.17sucai.com/pins/demo-show?id=2458 很多资料 ,前 ...