jsp页面实现数据转换显示 日期解析 按钮单击发送请求

1.在JSP页面上对响应的数据进行判断,显示对应提示:

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<%--将响应数据进行替换,如果为1显示开启,为0显示关闭 --%>
	<td class="text-center">
			<c:if test="${product.productStatus==1}">
				开启
			</c:if>
			<c:if test="${product.productStatus==0}">
				关闭
			</c:if>
		</td>

2.将时间进行格式化显示

<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


<td>
<%-- 将时间进行格式化--%>
		<fmt:formatDate  value="${product.departureTime}" pattern="yyyy-MM-dd HH:ss:mm"/>
</td>

3.简洁按钮单击请求事件设置

	<button type="button" class="btn btn-default" title="刷新"
	onclick="location.href='${pageContext.request.contextPath}/product/findAll.do'"	>
			<i class="fa fa-refresh"></i> 刷新
		</button>

3.1 ajax实现提交或请求

//	给复选框设置单击事件
		$("#checkOne").click(function () {
				location.href="${pageContext.request.contextPath}/xxx/xxx"
		});

3.2单击实现复选框外套Form表单提交
设置checkbox的value属性为当前行的主键,提交至Controller页面为字符串数组.

<form action="${pageContext.request.contextPath}/orders/remove.do" method="post" id="removeForm">

<table id="dataList"
	class="table table-bordered table-striped table-hover dataTable">
	<thead>
		<tr>
			<th class="" style="padding-right: 0px;"><input
				id="selall" type="checkbox" class="icheckbox_square-blue">
			</th>
			<th class="sorting_asc">ID</th>
			<th class="sorting_desc">订单编号</th>
			<th class="sorting_asc sorting_asc_disabled">产品名称</th>
			<th class="sorting_desc sorting_desc_disabled">金额</th>
			<th class="sorting">下单时间</th>
			<th class="text-center sorting">订单状态</th>
			<th class="text-center">操作</th>
		</tr>
	</thead>
	<tbody>
<!-- 循环遍历响应对象属性.-->
		<c:forEach items="${ordersList}" var="orders">
			<tr>
				<td><input name="ids" type="checkbox" value="${orders.id}"></td>
				<td>${orders.id}</td>
				<td>${orders.orderNum}</td>
				<td>${orders.product.productName}</td>
				<td>${orders.product.productPrice}</td>
				<td>
					<fmt:formatDate value="${orders.orderTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td class="text-center">
					<c:if test="${orders.orderStatus==1}" >开启</c:if>
					<c:if test="${orders.orderStatus==0}" >关闭</c:if>
			 	</td>
				</tr>
				</c:forEach>
			</tbody>
</table>
</form>


	//删除选中的订单数据
		$("#removeOrder").click(function () {
			 $("#removeForm").submit();
		});

3.3Controller接收数据

  @RequestMapping("/remove.do")
    @ResponseBody
    public Boolean remove(String [] ids) {
        for (String id : ids) {
            System.out.println(id);
        }

        return true;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值