陈旧的开发模式
美工(ui工程师:出一个项目模型)
java工程师:将原有的html转成jsp,动态展示数据
缺点:
客户需要调节前端的展示效果
解决:由美工去重新排版,重新选色。
Vs
前后端分离
美工、java工程师都是独立工作的,彼此之间在开发过程中是没有任何交际。
在开发前约定数据交互的格式。
java工程师的工作:写方法返回数据如tree_data1.json
美工:只管展示tree_data1.json

先看下dao方法

public class UserDao extends JsonBaseDao {
/**
* 用户登录或者查询用户分页信息的公共方法
*
* @param paMap
* @param pageBean
* @return
* @throws InstantiationException
* @throws IllegalAccessException
* @throws SQLException
*/
public List<Map<String, Object>> list(Map<String, String[]> paMap, PageBean pageBean)
throws InstantiationException, IllegalAccessException, SQLException {
String sql = "select * from t_easyui_user_version2 where true";
String uid = JsonUtils.getParamVal(paMap, "uid");
String upwd = JsonUtils.getParamVal(paMap, "upwd");
if (StringUtils.isNotBlank(uid)) {
sql += " and uid=" + uid;
}
if (StringUtils.isNotBlank(upwd)) {
sql += " and upwd=" + upwd;
}
return super.executeQuery(sql, pageBean);
} /**
* 修改
* @param paMap
* @return
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/
public int edit(Map<String, String[]> paMap) throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException, SQLException {
String sql = "update t_easyui_user_version2 set uid=?,uname=?,upwd=? where SerialNo=?";
return super.executeUpdate(sql, new String[] { "uid", "uname", "upwd", "SerialNo" }, paMap);
}
/**
* 新增
* @param paMap
* @return
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/ public int add(Map<String, String[]> paMap) throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException, SQLException {
String sql = "insert into t_easyui_user_version2 values(?,?,?)";
return super.executeUpdate(sql, new String[] { "uid", "uname", "upwd" }, paMap);
}
/**
* 删除
* @param paMap
* @return
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/ public int del(Map<String, String[]> paMap) throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException, SQLException {
String sql = "delete from t_easyui_user_version2 where SerialNo=?";
return super.executeUpdate(sql, new String[] {"SerialNo"}, paMap);
} /**
* 根据当前用户登录的ID去查询对应的所有菜单
*
* @param paMap
* @param pageBean
* @return
* @throws InstantiationException
* @throws IllegalAccessException
* @throws SQLException
*/
public List<Map<String, Object>> getMenuByUid(Map<String, String[]> paMap, PageBean pageBean)
throws InstantiationException, IllegalAccessException, SQLException {
String sql = "select * from t_easyui_usermenu where true";
String uid = JsonUtils.getParamVal(paMap, "uid");
if (StringUtils.isNotBlank(uid)) {
sql += " and uid=" + uid;
}
return super.executeQuery(sql, pageBean);
} }

userAction

public class UserAction extends ActionSupport{
private UserDao userDao=new UserDao();
/**
* 登录成功后跳转index.jsp
* @param request
* @param response
* @return
* @throws SQLException
* @throws IllegalAccessException
* @throws InstantiationException
*/
public String login(HttpServletRequest request,HttpServletResponse response){
//系统中是否有当前登录用户
Map<String, Object> map =null;
try {
map = this.userDao.list(request.getParameterMap(), null).get();
//有
if(map!=null&&map.size()>) {
//[{menuid:002,....},{menuid:003,....}]
//002,003
StringBuilder sb=new StringBuilder();
List<Map<String, Object>> menuIdArr = this.userDao.getMenuByUid(request.getParameterMap(), null);
for (Map<String, Object> m : menuIdArr) {
sb.append(","+m.get("menuId"));
}
request.setAttribute("menuIds",sb.substring());
return "index";
}else {
request.setAttribute("msg","用户不存在");
return "login";
}
} catch (InstantiationException | IllegalAccessException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//查询用户菜单中间表,获取menuid的集合
return null;
}
/**
* 数据表格datagrid加载方法?
* @param request
* @param response
* @return
* @throws Exception
*/
public String list(HttpServletRequest request,HttpServletResponse response) throws Exception {
ObjectMapper om=new ObjectMapper();
PageBean pageBean=new PageBean();
pageBean.setRequest(request);
List<Map<String, Object>> list = this.userDao.list(request.getParameterMap(), pageBean);
System.err.println(list);
//[{},{},{}]-->{"total":28,"rows":[{},{},{}]}
Map<String, Object> map=new HashMap<>();
map.put("total", pageBean.getTotal());
map.put("rows", list);
ResponseUtil.write(response,om.writeValueAsString(map));
return null;
}
/**
* from组件提交方法?
* @param request
* @param response
* @return
* @throws Exception
*/
public String edit(HttpServletRequest request,HttpServletResponse response) throws Exception {
int code = this.userDao.edit(request.getParameterMap());
ObjectMapper om=new ObjectMapper();
Map<String, Object> map=new HashMap<>();
map.put("code", code);
ResponseUtil.write(response,om.writeValueAsString(map));
return null;
}
/**
* 新增
* @param request
* @param response
* @return
* @throws Exception
*/
public String add(HttpServletRequest request,HttpServletResponse response) throws Exception {
int code = this.userDao.add(request.getParameterMap());
ObjectMapper om=new ObjectMapper();
Map<String, Object> map=new HashMap<>();
map.put("code", code);
ResponseUtil.write(response,om.writeValueAsString(map));
return null;
}
/**
* 删除
* @param req
* @param resp
* @return
* @throws InstantiationException
* @throws IllegalAccessException
* @throws SQLException
* @throws Exception
*/
public String del(HttpServletRequest req,HttpServletResponse resp) throws InstantiationException, IllegalAccessException, SQLException, Exception {
int code=this.userDao.del(req.getParameterMap());
ObjectMapper om = new ObjectMapper();
Map<String, Object> map = new HashMap<>();
map.put("code", code);
ResponseUtil.write(resp, om.writeValueAsString(map));
return null;
} }

后台就是代码,下面看下前端代码

userManage.js

$(function(){
$('#dg').datagrid({
url:'../userAction.action?methodName=list',
//行填充
fit:true,
//列填充
fitColumns:true,
//分页
pagination:true,
singleSelect:true,
columns:[[
{field:'uid',title:'ID',width:},
{field:'uname',title:'用户名',width:},
{field:'upwd',title:'密码',width:,align:'right'}
]],
//添加按钮
toolbar: [{
iconCls: 'icon-add',
handler: function(){
$('#ff').form('clear');//清空文本框的值
$('#dd').dialog('open');//打开表格
$("#dd").attr("title","增加用户");//增加信息
$("#method").val("add"); //通过隐藏ID来设置增加方法
}
},'-',{
iconCls: 'icon-edit',
handler: function(){
$('#dd').dialog('open');
// 到datagrid控件中找需要回填的数据(区别于原来从后台查询)
var row = $('#dg').datagrid('getSelected');
if(row){
// get_data.php指的是回填的数据
$('#ff').form('load',row);
$('#method').val('edit');
}else{
alert("请选择你要修改的行");
}
}
},'-',{
iconCls: 'icon-remove',
handler: function(){
var row =$('#dg').datagrid('getSelected');
if(row){
$.ajax({
url:$("#ctx").val()+'/userAction.action?methodName=remove&&SerialNo='+row.SerialNo,
});
$('#dg').datagrid('reload');//刷新方法
alert('删除成功');
}
else{
alert('删除失败');
}
}
},'-',{
iconCls: 'icon-reload',
handler: function(){alert('刷新按钮')}
}] }); })
function ok(){
$('#ff').form('submit', {
url:'../userAction.action?methodName=edit',
success:function(data){
$('#ff').form('clear')
$('#dd').dialog('close');
$('#dg').datagrid('reload');
//针对于后端返回的结果进行处理
}
}); }

userManage.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/js/public/easyui5/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/js/public/easyui5/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/public/easyui5/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/public/easyui5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/userManage.js"></script>
<!--展示数据 -->
<title>人员信息管理维护界面</title>
</head>
<body>
<table id="dg"></table>
<!--弹窗 -->
<div id="dd" class="easyui-dialog" title="编辑窗体" style="width:400px;height:200px;"
data-options="iconCls:'icon-save',resizable:true,modal:true,closed:true,buttons:'#bb'">
Dialog Content. <!--提交form 表单 -->
<form id="ff" method="post">
<input type="hidden" name="SerialNo">
<div>
<label for="uid">uid:</label>
<input class="easyui-validatebox" type="text" name="uid" />
</div> <br>
<div>
<label for="uname">uname:</label>
<input class="easyui-validatebox" type="text" name="uname" />
</div>
<div> <br>
<label for="uname">upwd:</label>
<input class="easyui-validatebox" type="text" name="upwd" />
</div>
</form>
<div id="bb">
<a href="#" id="name" class="easyui-linkbutton" value="edit" onclick="ok()">保存</a>
<a href="#" class="easyui-linkbutton">关闭</a>
</div> </div>
</body>
</html>

easyui三的更多相关文章

  1. 玩转Web之easyui(三)-----easy ui dataGird 重新指定url以获取不同数据源信息

    如果已经写了一个dataGird并且已经通过url绑定数据源,能不能在其他地方改变url使其从不同数据源获取信息,从而实现查询等操作?答案当然是肯定的,而且仅需要几行代码 $('#btnq').bin ...

  2. EF6 CodeFirst+Repository+Ninject+MVC4+EasyUI实践(三)

    前言 在上一篇中,我们依靠着EasyUI强大的前端布局特性把前端登录界面和主界面给搭建完成了.这一篇我们就要尝试着把整个解决方案部署到云端呢,也就是Visual Studio Online(TFVC) ...

  3. 我的权限系统设计实现MVC4 + WebAPI + EasyUI + Knockout(三)图形化机构树

    一.前言 组织机构是国内管理系统中很重要的一个概念,以前我们基本都是采用数据列表的形式展现,最多只是采用树形列表展现.虽然够用,但是如果能做成图形化当然是最好不过了.这里我不用任何图形控件,就用最原始 ...

  4. ASP.NET MVC +EasyUI 权限设计(三)基础模块

    请注明转载地址:http://www.cnblogs.com/arhat 在上一章中呢,我们基本上搭建好了环境,那么本章我们就从基础模块开始写起.由于用户,角色,动作三个当中,都是依赖与动作的,所以本 ...

  5. 第二百三十节,jQuery EasyUI,后台管理界面---后台管理

    jQuery EasyUI,后台管理界面---后台管理 一,admin.php,后台管理界面 <?php session_start(); if (!isset($_SESSION['admin ...

  6. abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理三 (二十一)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...

  7. (三)easyUI之树形组件

    一.同步树 1.1 概念 所有节点一次性加载完成 1.2 案例 1.2.1 数据库设计 1.2.2 编码 index.jsp <%@ page language="java" ...

  8. abp(net core)+easyui+efcore实现仓储管理系统——入库管理之一(三十七)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...

  9. EasyUI tree的三种选中状态

    EasyUI中tree有三种选中状态,分别是checked(选中).unchecked(未选中).indeterminate(部分选中). 其中indeterminate状态比较特殊,主要表示只有部分 ...

随机推荐

  1. ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/itsdangerous' Consider using the `--user` option or check the permissions

    近期练习flask写个blog, 安装flask扩展时 pip install Flask-WTF 报ERROR: Could not install packages due to an Envir ...

  2. Linux系统学习 五、网络基础—网络通信协议

    OSI/ISO七层模型和TCP/IP四层模型 网络层协议和IP划分 OSI的七层框架 物理层:设备之间的比特流的传输.物理接口.电气特性等. 数据链路层:成帧.用MAC地址访问媒介.错误检测与修正. ...

  3. CQRS(Command and Query Responsibility Segregation)与EventSources实例

    CQRS The CQRS pattern and event sourcing are not mere simplistic solutions to the problems associate ...

  4. Druid-代码段-3-1

    所属文章:池化技术(一)Druid是如何管理数据库连接的? 本代码段对应主流程3,新增连接的守护线程: //DruidDataSource的内部类,对应主流程3,用来补充连接 public class ...

  5. Redux使用

    思想 应用中所有的state都以一个对象树的形式储存在一个单一的store中.唯一能改变state的办法是触发action,一个描述发生什么的对象.为了描述action如何改变state树,需要编写r ...

  6. 201871010113-刘兴瑞《面向对象程序设计(java)》第十四周学习总结

    项目 内容 这个作业属于哪个课程 <任课教师博客主页链接>https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 <作业链接地址>http ...

  7. 浅谈vue中的计算属性和侦听属性

    计算属性 计算属性用于处理复杂的业务逻辑 计算属性具有依赖性,计算属性依赖 data中的初始值,只有当初始值改变的时候,计算属性才会再次计算 计算属性一般书写为一个函数,返回了一个值,这个值具有依赖性 ...

  8. 史上最全的CSP2019复习指南

    CSP2019复习指南 知识点(大纲)内容参考于本人博客: 近22年NOIP考点一览 算法 基本算法: 模拟.暴力枚举.排序.贪心.递归.递推.贪心.二分.位运算 这些算法不再在此加以赘述,如有考前还 ...

  9. Python爬取6271家死亡公司数据,一眼看尽十年创业公司消亡史!

    ​ 小五利用python将其中的死亡公司数据爬取下来,借此来观察最近十年创业公司消亡史. 获取数据 F12,Network查看异步请求XHR,翻页. ​ 成功找到返回json格式数据的url, 很多人 ...

  10. SpringBoot系列之配置文件加载位置

    SpringBoot系列之配置文件加载位置 SpringBoot启动会自动扫描如下位置的application.properties或者application.yml文件作为Springboot的默认 ...