【Java Web】【8】SSM 查询页思路

spring+struts+mybatis整合方式为spring整合struts和mybatis,struts作为表现层,mybatis作为持久层

简易理解:
1.    前台传值
a.    查询页面


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>公司信息管理</title>
<jsp:include page="../../no_auth_top.jsp"></jsp:include>
<link rel="stylesheet" href="${base}/web/css/crud.css?t=${time}">
</head>

<body>
	<!-- loading -->
	<span id="loading" class="loading icon-spinner icon-spin icon-3x"></span>

	<div id="layout" class="easyui-layout"
		style="overflow:hidden;width:100%;height:100%;visibility:hidden;">
		<div data-options="region:'north',border:false"
			style="overflow:hidden;border-bottom:1px #ddd solid;">
			<div class="business-title">
				<div class="business-icon">
					<i class="icon-book"></i>
				</div>
				<span class="spantitle">公司信息管理</span>
			</div>
			<div class="business-tools">
				
				<%-- <input 
						id="companyname"
						style="width:150px;"
						class="easyui-combobox" 
						data-options="
							required: true,
							editable: false,
							panelHeight: 200,
							url: '${base}/company_all.do',
							loadFilter: searchNameFilter,
							onChange: function(nv) {
								Bean.refreshGrid();
							}
						"> --%>
			
				<select  
					class="easyui-combobox"  
					editable="false"  
					id="companytype_sr"  
					style="width:200px;" 
					data-options="
						onChange: function(nv) {
							companyNameSearch();
						}
					"
				>
					<option value="运维公司" selected>运维公司</option>
					<option value="项目公司" >项目公司</option>
				</select>
			
				<input 
					id="companyname_sr"
					style="width:250px;"
					class="easyui-searchbox" 
					data-options="
						onChange: function(nv) {
							companyNameSearch();
						},
					prompt:'请输入公司名称'" 
					>
				<a class="easyui-linkbutton" οnclick="Bean.openAddPage()" style="padding:0px 10px;">新建</a>
			</div>
		</div>
		<div data-options="region:'center',border:false"
			style="overflow:hidden;">
			<div id="grid" fit="true" border="false"></div>
		</div>
	</div>
	
	<script type="text/javascript">
	
	/**
	 * 作为查询条件时车牌过滤器
	 */
	function searchNameFilter(rs) {
		var ds = nameFilter(rs);
		ds.unshift({value:'', text: '所有公司'});
		return ds;
	}
	
	/**
	 * 正常状态车牌过滤器
	 */
	function nameFilter(rs) {
		var rows = $.isArray(rs) ? rs : rs.rows;
		var newRS = [];
		for (var i = 0; i < rows.length; i++) {
			var row = rows[i];
			if (0 == row.state) continue;
			newRS.push({
				value: row.companyname,
				text: row.companyname
			});
		}
		return newRS;
	}
	
	//公司关键字搜索
	function companyNameSearch() {
		Grid.grid.load({
			"qm.companyname": $("#companyname_sr").val(), "qm.companytype": $("#companytype_sr").val()
		});
	}
	
		// 业务对象
		var Bean = {
			modRow: {},	// 缓存要编辑的行
				
			// 列表请求地址
			listUrl: base + "/company_list.do",
			// 列表元素页面ID
			gridID: "grid",
			// 列配置
			columns: [
				{field: 'companyname', title:'公司名称', width:35, formatter: function(v, r, i) {
					return "<a class='link-grid' οnclick='Bean.openDetailPageInIframe(\""+ r.companyid +"\")'>"+ v +"</a>";
				}},	
				{field: 'companycode', title:'纳税人识别号', width:30},	
				{field: 'companyaddress', title:'企业经营地址', width:25, align: "center"},
				{field: 'companyaccount', title:'开户行以及账号', width:25, align: "center"},
				{field: 'companytel', title:'联系电话', width:25, align: "center"},
				{field: 'companyremark', hidden:true, title:'备注', width:40, align: "left"},
				{field: 'companytype', title:'公司类型', width:25, align: "center"},
				{field: 'companyorderno', title:'排序号', width:25, align: "center"},
				{field: 'op', title:'操作', align: "right", width:25, formatter: function(v, r, i) {
					return opFormatter(/* {
						name: "详情",
						id: r.companyid,
						click: "Bean.openDetailPageInIframe"
					}, */
					{
						name: "编辑",
						index: i,
						click: "Bean.mod"
					},{
						name: "删除",
						id: r.companyid,
						click: "Bean.delete"
					});
				}}
			],
			
			// 新增页面地址
			newUrl: base + "/web/page/company/company_add.jsp",
			newTitle: "新增公司信息",
			
			// 修改页面地址
			modUrl: base + "/web/page/company/company_mod.jsp",
			modTitle: "编辑公司信息",
			
			// 删除url
			deleteUrl: base + "/company_delete.do",
			deleteField: "bean.companyid",
			
			// 详情页配置
			detailUrlInIframe: base + "/web/page/company/company_detail.jsp"
		};	

		//layout布局显示完毕
		page.layoutComplete = function() {
			Bean.init();
			Grid.grid.load({
				"qm.companyname": $("#companyname_sr").val(), "qm.companytype": $("#companytype_sr").val()
			});
		}
		
	</script>

	<script type="text/javascript"
		src="${base}/web/script/crud.js?t=${time}"></script>
</body>
</html>

通过url:company_list.do,进入companyAction中,

	public void list(){
		Result result = new Result();

		try {
			if (null == bean) bean = new CompanyBean();
			if (qm == null) qm = new HashMap<String, Object>();
			bean.setQm(qm);
			bean.setCurrentPage(page);
			bean.setLimit(rows);
			bean.setPage();

			List<CompanyBean> list = companyService.getList(bean);
			result.setRows(list);
			result.setTotal(companyService.getListCount(bean));
		} catch (Exception e) {
			e.printStackTrace();
			log.error("[CompanyAction.list] 查询列表出错", e);
			result.fail();
		}
		ResponseUtil.sendResult(result.toJSONString());
	}
查询出来的值保存到bean中,前台通过bean再遍历到页面
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值