随笔 - 434,  文章 - 0,  评论 - 463,  阅读 - 46万

1.引入资源包

在上一节中,我们把基本的框架都搭好了,用了Spring,SPringMVC。这一节,我们先来画页面,前端框架采用EasyUI来实现。
easyui是一种基于jQuery的用户界面插件集合,使用easyui我们就不需要写很多代码,只需要通过编写一些简单HTML标记,就可以定义用户界面。
现在,我们把easyui需要的资源包拷贝进来。

2.绘制主界面

界面的话,我们就用html来实现吧,在WebContent目录下新建一个页面叫index.html。

目录结构如下:

代码:

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>学生管理主界面</title>

	<!-- 引入EasyUI资源文件 -->
	<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.3/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.3/themes/icon.css">
	<script type="text/javascript" src="jquery-easyui-1.3.3/jquery.min.js"></script>
	<script type="text/javascript" src="jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>


</head>
<body>

</body>
</html>

现在,我们来画四个按钮:

   <!-- 工具栏 -->
	<div id="toolbar">
		<a href="javascript:openUserAddPage()" class="easyui-linkbutton" iconCls="icon-add" >新增用户</a>
		<a href="javascript:openUserModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" >编辑用户</a>
		<a href="javascript:delUser()" class="easyui-linkbutton" iconCls="icon-remove">删除用户</a>
		<a href="javascript:resetPassword()" class="easyui-linkbutton" iconCls="icon-modifyPassword">密码重置</a>
	</div>
可以看到每一个按钮都是用a标签来做的,我们给每一个a标签添加一个 easyui-linkbutton 的class,就可以实现这一效果:

同时,每一个按钮还有一个点击事件,对应的函数我们先不写,预留一个接口。

接下来,我们绘制搜索栏,到时候可以根据某些条件来查询学生数据。

代码:

	<!-- 搜索栏 -->
	<div id="searchBox">
		&nbsp;用户名&nbsp;<input type="text" id="username_search" size="20" onkeydown="if(event.keyCode==13) searchUser()"/>
		&nbsp;昵称&nbsp;<input type="text" id="nickname_search" size="20" onkeydown="if(event.keyCode==13) searchUser()"/>
		
		<a href="javascript:searchUser()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
	</div>

自定义css样式:

#searchBox{
	margin-top: 16px;
    background: #fff8f8;
    padding: 4px;
    font-size: 14px;
    width: 500px;
}
页面效果:

最后,画数据列表,我们使用easyUI给我们提供的datagrid组件来实现:

   <br>
	
	<!-- 数据列表 -->
	<table id="grid0" class="easyui-datagrid" title="用户列表" style="width:980px;height:550px"
			data-options="pagination:true,pageSize:10,rownumbers:true,fitColumns:true,
			singleSelect:false,collapsible:false,url:''">
		<thead>
			<tr>
				<th data-options="field:'ck',checkbox:true"></th>
				<th data-options="field:'username',width:80">用户名</th>
				<th data-options="field:'password',width:100">密码</th>
				<th data-options="field:'nickname',width:120">昵称</th>
				<th data-options="field:'xb',width:0,hidden:true" >性别</th>
				<th data-options="field:'vip',width:0,hidden:true">贵族等级</th>
				<th data-options="field:'xb_displayname',width:80" >性别</th>
				<th data-options="field:'vip_displayname',width:80">贵族等级</th>
				<th data-options="field:'createtime',width:250"">创建时间</th>
				<th data-options="field:'updatetime',width:250">最后更新时间</th>
			</tr>
		</thead>
	</table>

最终效果:

打开浏览器访问:http://localhost/student/index.html 即可看到该页面。

本节我们就简单的画一个页面,下一讲我们继续写后台代码。

posted on   剽悍一小兔  阅读(1112)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示