zoukankan      html  css  js  c++  java
  • 【Java框架型项目从入门到装逼】第八节

    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;
         500px;
    }
    

    页面效果:

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

       <br>
    	
    	<!-- 数据列表 -->
    	<table id="grid0" class="easyui-datagrid" title="用户列表" style="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',80">用户名</th>
    				<th data-options="field:'password',100">密码</th>
    				<th data-options="field:'nickname',120">昵称</th>
    				<th data-options="field:'xb',0,hidden:true" >性别</th>
    				<th data-options="field:'vip',0,hidden:true">贵族等级</th>
    				<th data-options="field:'xb_displayname',80" >性别</th>
    				<th data-options="field:'vip_displayname',80">贵族等级</th>
    				<th data-options="field:'createtime',250"">创建时间</th>
    				<th data-options="field:'updatetime',250">最后更新时间</th>
    			</tr>
    		</thead>
    	</table>
    

    最终效果:

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

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

  • 相关阅读:
    java Object类是可以接收集合类型的
    java.lang.String中[ "张飞"+1+1 ] 和 [ "张飞"+(1+1) ]
    AFL Fuzz入门
    [转载]linux与grep
    linux下安装clamav
    [转载]Linux连续执行多条命令
    [转载]linux下各文件夹的结构说明及用途介绍
    [转载]linux常用命令
    [转载]Ubuntu 16.04 蓝屏解决方案
    pycharm修改python版本
  • 原文地址:https://www.cnblogs.com/skyblue-li/p/8257223.html
Copyright © 2011-2022 走看看