.net Json JavaScriptSerializer JsonHelper类

结合.net 的JavaScriptSerializer 类实现Json数据处理

调用1:

     Model.Users m = BLL.UsersBLL.GetUserById(Convert.ToInt32(id));string result = "";if (m != null)result = JsonHelper.ObjectToJSON(m);context.Response.Write(result);    

 调用2:

    Hashtable ht = new Hashtable();List<Model.UsersModel> resultlist = BLL.UsersBLL.GetUsersList(type, begin, end, page, 4, ht);string result = JsonHelper.ObjectToJSON(new{@list = resultlist,@today = DateTime.Now.ToString("yyyy-MM-dd"),@pageIndex = page,@recordCount = ht["rowcount"],@pageCount = ht["pagecount"]});context.Response.Write(result);
//
前台JS调用Json数据

$.ajax({
url: "../handler/zeji.ashx",
type: "POST",
data: "type=" + type + "&time=" + time + "&page=" + page,
//completed: $("#indicator").hide(),
success: function (data) {
data = eval("(" + data + ")");

   for (var i = 0; i < data.list.length; i++) {

    var riqi = data.list[i].Riqi.toString();

 }

var recordCount = data.recordCount;

}

});

 

 

JsonHelper 类

public class JsonHelper
{#region 私有方法/// <summary>/// 过滤特殊字符/// </summary>private static string StringToJson(String s){StringBuilder sb = new StringBuilder();for (int i = 0; i < s.Length; i++){char c = s.ToCharArray()[i];switch (c){case '\"':sb.Append("\\\""); break;case '\\':sb.Append("\\\\"); break;case '/':sb.Append("\\/"); break;case '\b':sb.Append("\\b"); break;case '\f':sb.Append("\\f"); break;case '\n':sb.Append("\\n"); break;case '\r':sb.Append("\\r"); break;case '\t':sb.Append("\\t"); break;default:sb.Append(c); break;}}return sb.ToString();}/// <summary>/// 格式化字符型、日期型、布尔型/// </summary>private static string StringFormat(string str, Type type){if (type == typeof(string)){str = StringToJson(str);str = "\"" + str + "\"";}else if (type == typeof(DateTime)){str = "\"" + str + "\"";}else if (type == typeof(bool)){str = str.ToLower();}else if (type != typeof(string) && string.IsNullOrEmpty(str)){str = "\"" + str + "\"";}return str;}#endregion#region List转换成Json/// <summary>/// List转换成Json/// </summary>public static string ListToJson<T>(IList<T> list){object obj = list[0];return ListToJson<T>(list, obj.GetType().Name);}/// <summary>/// List转换成Json /// </summary>public static string ListToJson<T>(IList<T> list, string jsonName){StringBuilder Json = new StringBuilder();if (string.IsNullOrEmpty(jsonName)) jsonName = list[0].GetType().Name;Json.Append("{\"" + jsonName + "\":[");if (list.Count > 0){for (int i = 0; i < list.Count; i++){T obj = Activator.CreateInstance<T>();PropertyInfo[] pi = obj.GetType().GetProperties();Json.Append("{");for (int j = 0; j < pi.Length; j++){Type type = pi[j].GetValue(list[i], null).GetType();Json.Append("\"" + pi[j].Name.ToString() + "\":" + StringFormat(pi[j].GetValue(list[i], null).ToString(), type));if (j < pi.Length - 1){Json.Append(",");}}Json.Append("}");if (i < list.Count - 1){Json.Append(",");}}}Json.Append("]}");return Json.ToString();}#endregion#region 对象转换为Json/// <summary> /// 对象转换为Json /// </summary> /// <param name="jsonObject">对象</param> /// <returns>Json字符串</returns> public static string ToJson(object jsonObject){string jsonString = "{";PropertyInfo[] propertyInfo = jsonObject.GetType().GetProperties();for (int i = 0; i < propertyInfo.Length; i++){object objectValue = propertyInfo[i].GetGetMethod().Invoke(jsonObject, null);string value = string.Empty;if (objectValue is DateTime || objectValue is Guid || objectValue is TimeSpan){value = "'" + objectValue.ToString() + "'";}else if (objectValue is string){value = "'" + ToJson(objectValue.ToString()) + "'";}else if (objectValue is IEnumerable){value = ToJson((IEnumerable)objectValue);}else{value = ToJson(objectValue.ToString());}jsonString += "\"" + ToJson(propertyInfo[i].Name) + "\":" + value + ",";}jsonString.Remove(jsonString.Length - 1, jsonString.Length);return jsonString + "}";}#endregion#region 对象集合转换Json/// <summary> /// 对象集合转换Json /// </summary> /// <param name="array">集合对象</param> /// <returns>Json字符串</returns> public static string ToJson(IEnumerable array){string jsonString = "[";foreach (object item in array){jsonString += ToJson(item) + ",";}jsonString.Remove(jsonString.Length - 1, jsonString.Length);return jsonString + "]";}#endregion#region 普通集合转换Json/// <summary> /// 普通集合转换Json /// </summary> /// <param name="array">集合对象</param> /// <returns>Json字符串</returns> public static string ToArrayString(IEnumerable array){string jsonString = "[";foreach (object item in array){jsonString = ToJson(item.ToString()) + ",";}jsonString.Remove(jsonString.Length - 1, jsonString.Length);return jsonString + "]";}#endregion#region Object转JSON/// <summary>/// 对象转JSON/// </summary>/// <param name="obj">对象</param>/// <returns>JSON格式的字符串</returns>public static string ObjectToJSON(object obj){JavaScriptSerializer jss = new JavaScriptSerializer();try{return jss.Serialize(obj);}catch (Exception ex){throw new Exception("JSONHelper.ObjectToJSON(): " + ex.Message);}}#endregion#region  DataSet转换为Json/// <summary> /// DataSet转换为Json /// </summary> /// <param name="dataSet">DataSet对象</param> /// <returns>Json字符串</returns> public static string ToJson(DataSet dataSet){string jsonString = "{";foreach (DataTable table in dataSet.Tables){jsonString += "\"" + table.TableName + "\":" + ToJson(table) + ",";}jsonString = jsonString.TrimEnd(',');return jsonString + "}";}#endregion#region DataSet转键值对数组字典/// <summary>/// 数据集转键值对数组字典/// </summary>/// <param name="dataSet">数据集</param>/// <returns>键值对数组字典</returns>public static Dictionary<string, List<Dictionary<string, object>>> DataSetToDic(DataSet ds){Dictionary<string, List<Dictionary<string, object>>> result = new Dictionary<string, List<Dictionary<string, object>>>();foreach (DataTable dt in ds.Tables)result.Add(dt.TableName, DataTableToList(dt));return result;}#endregion#region Datatable转换为Json/// <summary> /// Datatable转换为Json /// </summary> /// <param name="table">Datatable对象</param> /// <returns>Json字符串</returns> public static string ToJson(DataTable dt){StringBuilder jsonString = new StringBuilder();jsonString.Append("[");DataRowCollection drc = dt.Rows;for (int i = 0; i < drc.Count; i++){jsonString.Append("{");for (int j = 0; j < dt.Columns.Count; j++){string strKey = dt.Columns[j].ColumnName;string strValue = drc[i][j].ToString();Type type = dt.Columns[j].DataType;jsonString.Append("\"" + strKey + "\":");strValue = StringFormat(strValue, type);if (j < dt.Columns.Count - 1){jsonString.Append(strValue + ",");}else{jsonString.Append(strValue);}}jsonString.Append("},");}jsonString.Remove(jsonString.Length - 1, 1);jsonString.Append("]");return jsonString.ToString();}/// <summary>/// DataTable转换为Json /// </summary>public static string ToJson(DataTable dt, string jsonName){StringBuilder Json = new StringBuilder();if (string.IsNullOrEmpty(jsonName)) jsonName = dt.TableName;Json.Append("{\"" + jsonName + "\":[");if (dt.Rows.Count > 0){for (int i = 0; i < dt.Rows.Count; i++){Json.Append("{");for (int j = 0; j < dt.Columns.Count; j++){Type type = dt.Rows[i][j].GetType();Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + StringFormat(dt.Rows[i][j].ToString(), type));if (j < dt.Columns.Count - 1){Json.Append(",");}}Json.Append("}");if (i < dt.Rows.Count - 1){Json.Append(",");}}}Json.Append("]}");return Json.ToString();}#endregion#region DataTable转键值对集合/// <summary>/// 数据表转键值对集合/// 把DataTable转成 List集合, 存每一行/// 集合中放的是键值对字典,存每一列/// </summary>/// <param name="dt">数据表</param>/// <returns>哈希表数组</returns>public static List<Dictionary<string, object>> DataTableToList(DataTable dt){List<Dictionary<string, object>> list= new List<Dictionary<string, object>>();foreach (DataRow dr in dt.Rows){Dictionary<string, object> dic = new Dictionary<string, object>();foreach (DataColumn dc in dt.Columns){dic.Add(dc.ColumnName, dr[dc.ColumnName]);}list.Add(dic);}return list;}#endregion#region DataTable转List<T>/// <summary>/// DataTable转List<T>/// </summary>/// <typeparam name="T">数据项类型</typeparam>/// <param name="dt">DataTable</param>/// <returns>List数据集</returns>public static List<T> DataTableToList<T>(DataTable dt) where T : new(){List<T> tList = new List<T>();if (dt == null || dt.Rows.Count == 0){return tList;}PropertyInfo[] propertys = typeof(T).GetProperties();   //获取此实体的公共属性foreach (DataRow dr in dt.Rows){T t = new T();foreach (PropertyInfo pi in propertys){if (!pi.CanWrite){continue;}string columnName = pi.Name;if (dr.Table.Columns.Contains(columnName)){// 判断此属性是否有Setter或columnName值是否为空object value = dr[columnName];if (value is DBNull || value == DBNull.Value || value == null || !pi.CanWrite){continue;}#region SetValuetry{switch (pi.PropertyType.ToString()){case "System.String":pi.SetValue(t, Convert.ToString(value), null);break;case "System.ToChar":pi.SetValue(t, Convert.ToChar(value), null);break;case "System.Int64":pi.SetValue(t, Convert.ToInt64(value), null);break;case "System.Int32":pi.SetValue(t, Convert.ToInt32(value), null);break;case "System.ToUInt64":pi.SetValue(t, Convert.ToUInt64(value), null);break;case "System.ToUInt32":pi.SetValue(t, Convert.ToUInt32(value), null);break;case "System.DateTime":pi.SetValue(t, Convert.ToDateTime(value), null);break;case "System.Boolean":pi.SetValue(t, Convert.ToBoolean(value), null);break;case "System.Double":pi.SetValue(t, Convert.ToDouble(value), null);break;case "System.Decimal":pi.SetValue(t, Convert.ToDecimal(value), null);break;case "System.Single":pi.SetValue(t, Convert.ToSingle(value), null);break;default:pi.SetValue(t, value, null);break;}}catch{//throw (new Exception(ex.Message));
                    }#endregion}}tList.Add(t);}return tList;}#endregion#region DataTable转JSON/// <summary>/// 数据表转JSON/// </summary>/// <param name="dataTable">数据表</param>/// <returns>JSON字符串</returns>public static string DataTableToJSON(DataTable dt){return ObjectToJSON(DataTableToList(dt));}#endregion#region 泛型集合转DataTable/// <summary>/// 泛型集合转DataTable/// </summary>/// <typeparam name="T">集合类型</typeparam>/// <param name="entityList">泛型集合</param>/// <returns>DataTable</returns>public static DataTable ListToDataTable<T>(IList<T> entityList){if (entityList == null) return null;DataTable dt = CreateTable<T>();Type entityType = typeof(T);//PropertyInfo[] properties = entityType.GetProperties();PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(entityType);foreach (T item in entityList){DataRow row = dt.NewRow();foreach (PropertyDescriptor property in properties){row[property.Name] = property.GetValue(item);}dt.Rows.Add(row);}return dt;}#endregion#region 创建DataTable的结构/// <summary>/// 创建表结构/// </summary>/// <typeparam name="T"></typeparam>/// <returns></returns>private static DataTable CreateTable<T>(){Type entityType = typeof(T);//PropertyInfo[] properties = entityType.GetProperties();PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(entityType);//生成DataTable的结构DataTable dt = new DataTable();foreach (PropertyDescriptor prop in properties){dt.Columns.Add(prop.Name);}return dt;}#endregion#region DataReader转换为Json/// <summary> /// DataReader转换为Json /// </summary> /// <param name="dataReader">DataReader对象</param> /// <returns>Json字符串</returns> public static string ToJson(DbDataReader dataReader){StringBuilder jsonString = new StringBuilder();jsonString.Append("[");while (dataReader.Read()){jsonString.Append("{");for (int i = 0; i < dataReader.FieldCount; i++){Type type = dataReader.GetFieldType(i);string strKey = dataReader.GetName(i);string strValue = dataReader[i].ToString();jsonString.Append("\"" + strKey + "\":");strValue = StringFormat(strValue, type);if (i < dataReader.FieldCount - 1){jsonString.Append(strValue + ",");}else{jsonString.Append(strValue);}}jsonString.Append("},");}dataReader.Close();jsonString.Remove(jsonString.Length - 1, 1);jsonString.Append("]");return jsonString.ToString();}#endregion#region DataReader转实体/// <summary>/// DataReader转实体/// </summary>/// <typeparam name="T">数据类型</typeparam>/// <param name="dr">DataReader</param>/// <returns>实体</returns>public static T DataReaderToModel<T>(IDataReader dr) where T : new(){T t = new T();if (dr == null){dr.Close();return default(T);}using (dr){if (dr.Read()){PropertyInfo[] propertys = t.GetType().GetProperties(); //获取此实体的公共属性List<string> DBFieldNameList = new List<string>(dr.FieldCount);for (int i = 0; i < dr.FieldCount; i++){DBFieldNameList.Add(dr.GetName(i).ToLower());}foreach (PropertyInfo pi in propertys){if (!pi.CanWrite){continue;}string columnName = pi.Name;if (DBFieldNameList.Contains(columnName.ToLower())){//判断此属性是否有Setter或columnName值是否为空object value = dr[columnName];if (value is DBNull || value == DBNull.Value || value == null || !pi.CanWrite){continue;}#region SetValuetry{switch (pi.PropertyType.ToString()){case "System.String":pi.SetValue(t, Convert.ToString(value), null);break;case "System.ToChar":pi.SetValue(t, Convert.ToChar(value), null);break;case "System.Int64":pi.SetValue(t, Convert.ToInt64(value), null);break;case "System.Int32":pi.SetValue(t, Convert.ToInt32(value), null);break;case "System.ToUInt64":pi.SetValue(t, Convert.ToUInt64(value), null);break;case "System.ToUInt32":pi.SetValue(t, Convert.ToUInt32(value), null);break;case "System.DateTime":pi.SetValue(t, Convert.ToDateTime(value), null);break;case "System.Boolean":pi.SetValue(t, Convert.ToBoolean(value), null);break;case "System.Double":pi.SetValue(t, Convert.ToDouble(value), null);break;case "System.Decimal":pi.SetValue(t, Convert.ToDecimal(value), null);break;case "System.Single":pi.SetValue(t, Convert.ToSingle(value), null);break;default:pi.SetValue(t, value, null);break;}}catch{//throw (new Exception(ex.Message));
                        }#endregion}}}}dr.Close();return t;}#endregion#region DataReader转List<T>/// <summary>/// DataReader转List<T>/// </summary>/// <typeparam name="T">数据类型</typeparam>/// <param name="dr">DataReader</param>/// <returns>List数据集</returns>public static List<T> DataReaderToList<T>(IDataReader dr) where T : new(){List<T> tList = new List<T>();if (dr == null){dr.Close();return tList;}using (dr){PropertyInfo[] propertys = typeof(T).GetProperties();    //获取此实体的公共属性List<string> DBFieldNameList = new List<string>(dr.FieldCount);for (int i = 0; i < dr.FieldCount; i++){DBFieldNameList.Add(dr.GetName(i).ToLower());}while (dr.Read()){T t = new T();foreach (PropertyInfo pi in propertys){if (!pi.CanWrite){continue;}string columnName = pi.Name;if (DBFieldNameList.Contains(columnName.ToLower())){// 判断此属性是否有Setter或columnName值是否为空object value = dr[columnName];if (value is DBNull || value == DBNull.Value || value == null || !pi.CanWrite){continue;}#region SetValuetry{switch (pi.PropertyType.ToString()){case "System.String":pi.SetValue(t, Convert.ToString(value), null);break;case "System.ToChar":pi.SetValue(t, Convert.ToChar(value), null);break;case "System.Int64":pi.SetValue(t, Convert.ToInt64(value), null);break;case "System.Int32":pi.SetValue(t, Convert.ToInt32(value), null);break;case "System.ToUInt64":pi.SetValue(t, Convert.ToUInt64(value), null);break;case "System.ToUInt32":pi.SetValue(t, Convert.ToUInt32(value), null);break;case "System.DateTime":pi.SetValue(t, Convert.ToDateTime(value), null);break;case "System.Boolean":pi.SetValue(t, Convert.ToBoolean(value), null);break;case "System.Double":pi.SetValue(t, Convert.ToDouble(value), null);break;case "System.Decimal":pi.SetValue(t, Convert.ToDecimal(value), null);break;case "System.Single":pi.SetValue(t, Convert.ToSingle(value), null);break;default:pi.SetValue(t, value, null);break;}}catch{//throw (new Exception(ex.Message));
                        }#endregion}}tList.Add(t);}}dr.Close();return tList;}#endregion#region 序列化、反序列化/// <summary>/// 对象序列化/// </summary>/// <typeparam name="T"></typeparam>/// <param name="obj"></param>/// <returns></returns>public static String Serialize<T>(T obj){String s;JavaScriptSerializer ser = new JavaScriptSerializer();ser.MaxJsonLength = Int32.MaxValue;s = ser.Serialize(obj);/*DataContractJsonSerializer ser = new DataContractJsonSerializer(obj.GetType());using (MemoryStream ms = new MemoryStream()) {ser.WriteObject(ms, obj);s = Encoding.Default.GetString(ms.ToArray());}*/return s;}/// <summary>/// 反序列化/// </summary>/// <typeparam name="T"></typeparam>/// <param name="json"></param>/// <returns></returns>public static T Deserialize<T>(String json){JavaScriptSerializer jss = new JavaScriptSerializer();return jss.Deserialize<T>(json);//T o;//json = HttpContext.Current.Server.UrlDecode(json);//JavaScriptSerializer ser = new JavaScriptSerializer();//ser.MaxJsonLength = Int32.MaxValue;//o = ser.Deserialize<T>(json);//return o;/*o = Activator.CreateInstance<T>();using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) {DataContractJsonSerializer ser = new DataContractJsonSerializer(o.GetType());o = (T)(ser.ReadObject(ms));}*/}#endregion#region JSON文本转对象,泛型方法/// <summary>/// JSON文本转对象,泛型方法/// </summary>/// <typeparam name="T">类型</typeparam>/// <param name="jsonText">JSON文本</param>/// <returns>指定类型的对象</returns>public static T JSONToObject<T>(string jsonText){JavaScriptSerializer jss = new JavaScriptSerializer();try{return jss.Deserialize<T>(jsonText);}catch (Exception ex){throw new Exception("JSONHelper.JSONToObject(): " + ex.Message);}}#endregion#region 将JSON文本转换为数据表数据/// <summary>/// 将JSON文本转换为数据表数据/// </summary>/// <param name="jsonText">JSON文本</param>/// <returns>数据表字典</returns>public static Dictionary<string, List<Dictionary<string, object>>> TablesDataFromJSON(string jsonText){return JSONToObject<Dictionary<string, List<Dictionary<string, object>>>>(jsonText);}#endregion#region  将JSON文本转换成数据行/// <summary>/// 将JSON文本转换成数据行/// </summary>/// <param name="jsonText">JSON文本</param>/// <returns>数据行的字典</returns>public static Dictionary<string, object> DataRowFromJSON(string jsonText){return JSONToObject<Dictionary<string, object>>(jsonText);}#endregion
}

 后台Http请求

    /// <summary>/// /// </summary>/// <param name="url">网址</param>/// <param name="parase">参数</param>/// <param name="encoding">编码格式 </param>/// <returns></returns>public static string GetHttpPost(string url, string encoding){if (encoding == null)encoding = "gb2312";try{WebClient WC = new WebClient();WC.Headers.Add("Content-Type", "application/x-www-form-urlencoded");int p = url.IndexOf("?");string sData = url.Substring(p + 1);url = url.Substring(0, p);byte[] postData = Encoding.GetEncoding(encoding).GetBytes(sData);byte[] responseData = WC.UploadData(url, "POST", postData);string ct = Encoding.GetEncoding(encoding).GetString(responseData);return ct;}catch (Exception Ex){return Ex.Message;}}
View Code

 

转载于:https://www.cnblogs.com/yonsy/p/4446958.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/400496.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C语言实现的FFT与IFFT源代码,不依赖特定平台

目录源码FFT.cFFT.h使用方法初始化输入数据FFT 快速傅里叶变换解算FFT结果使用python绘制FFT波形IFFT 快速傅里叶逆变换解算IFFT结果Windows 10 20H2 Visual Studio 2015 Python 3.8.12 (default, Oct 12 2021, 03:01:40) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on …

在51单片机上使用递归的注意事项

目录问题应对措施原理普中51-单核-A2 STC89C52 Keil uVision V5.29.0.0 PK51 Prof.Developers Kit Version:9.60.0.0 问题 在Keil C51中直接使用递归会报如下警告&#xff1a; recursive call to non-reentrant function 为了提高运行效率&#xff0c;C51采用静态分配局部变量…

C盘瘦身:QQ文件的清理及Group2文件夹

目录问题解决方法Windows 10 20H2 TIM 问题 最近C盘被撑爆了 使用SpaceSniffer一扫发现QQ的文件中有个Group2文件夹占了我17G 但使用QQ自带的个人文件夹清理却扫不到&#xff0c;据说直接删除会丢失近期所有群聊的聊天图片 解决方法 在这个地方找到了大神fsz1987给出的解…

获取ArcGIS安装路径

在要素类进行符号化时&#xff0c;使用axSymbologyControl需要安装路径下的Style文件路径&#xff0c;在AE9.3VS2008中是这样的&#xff1a; Microsoft.Win32.RegistryKey regKey Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ESRI\\CoreRuntime",…

【51单片机快速入门指南】3.2:定时器/计数器

目录快速使用硬知识传统51单片机 CPU 时序的有关知识&#xff08;12T&#xff09;51 单片机定时器原理51 单片机定时/计数器结构定时器/计数器0/1定时器/计数器0和1的相关寄存器控制寄存器工作模式寄存器工作模式模式0(13位定时器/计数器)模式1(16位定时器/计数器)模式2(8位自动…

sublime_text 3 注册序列号

为什么80%的码农都做不了架构师&#xff1f;>>> ----- BEGIN LICENSE ---- Andrew Weber Single User License EA7E-855605 813A03DD 5E4AD9E6 6C0EEB94 BC99798F 942194A6 02396E98 E62C9979 4BB979FE 91424C9D A45400BF F6747D88 2FB88078 90F5CC94 1CDC92DC 845…

【51单片机快速入门指南】3.2.1:PWM、呼吸灯与舵机

目录硬知识PWM&#xff08;脉冲宽度调制&#xff09;基本原理脉宽调制分类上机实战呼吸灯main.c中断服务函数修改TIM.c中的中断服务函数效果开发板电路分析舵机控制舵机控制方法main.c中断服务函数修改中断服务函数舵机测试程序main.c效果普中51-单核-A2 STC89C52 Keil uVisio…

Proteus仿真单片机:51单片机的仿真

目录新建工程调试在Proteus中编写程序导入Keil生成的Hex程序Windows 10 20H2 Proteus 8 Frofessional v8.9 SP2 Keil uVision V5.29.0.0 PK51 Prof.Developers Kit Version:9.60.0.0 新建工程 设置名称和路径 下一步 下一步 选择系列、控制器和编译器 双击MCU设置主频 …

Linux 命令行输入

这几天刚刚接触到Linux&#xff0c;在windows上安装的VMWare虚拟机&#xff0c;Centos7。安装什么都是贾爷和办公室的同事帮忙搞定的。 在虚拟机界面&#xff0c;按快捷键CtrlAltEnter&#xff0c;可以全屏显示Linux界面&#xff0c;再按一次则退出全屏。 如何在Linux里输入命令…

【51单片机快速入门指南】2.5:并行I/O扩展与8255A

目录硬知识单片机I/O扩展基础知识I/O接口电路的功能速度协调输出数据锁存数据总线隔离数据转换增强驱动能力单片机并行扩展总线并行扩展总线的组成80C51单片机并行扩展总线I/O编址技术可编程并行接口芯片82558255硬件逻辑结构口电路总线接口电路A组和B组控制电路中断控制电路82…

win 下 apache2.4 +tomcat7 集群

为什么80%的码农都做不了架构师&#xff1f;>>> 反正每次来做一个不熟悉的东西&#xff0c;就是各种的search ,前一次去做过一个apache的东西&#xff0c;各种蛋疼&#xff0c;各种不能用。好多的东西也是比较旧了的咯。 这次结合前辈的各种东借西拿&#xff0c;总…

Proteus仿真单片机:PIC18单片机的仿真

目录新建工程ProteusMPLAB X IDE调试Windows 10 20H2 Proteus 8 Frofessional v8.9 SP2 MPLAB X IDE v5.45 新建工程 Proteus 下一步 下一步 选择芯片、编译器 搭建实验电路 MPLAB X IDE MPLAB X IDE 新建工程 选择独有项目 选择芯片 选择编译器 配置工程名称、路…

Realm学习总结

参考博客: http://www.jianshu.com/p/096bec929f2a http://www.cnblogs.com/ilyy/p/5648051.html 参考的博客介绍很详细,我就不写了..写了一个简单的学习的demo. GitHub地址: https://github.com/PengSiSi/RealmDemo 代码如下: // // ViewController.m // RealmDemo // // C…

with(nolock)的用法

with(nolock)的介绍 大家在写查询时,为了性能,往往会在表后面加一个nolock,或者是with(nolock),其目的就是查询是不锁定表,从而达到提高查询速度的目的。 当同一时间有多个用户访问同一资源,并发用户中如果有用户对资源做了修改&#xff0c;此时就会对其它用户产生某些不利的影…

【PIC18单片机学习笔记】一、程序的烧录

目录编程器烧录软件烧录准备程序main.cpic18.h烧录效果Windows 10 20H2 PICkit 3 v3.10 MPLAB X IDE v5.45 PIC18F46J50 编程器 所用编程器为PICkit 3.5 按图示连接好编程器和开发板 烧录软件 所用烧录软件为PICkit 3 v3.10 初次使用需要给编程器更新固件&#xff0c…

ASIHttpRequest:创建队列、下载请求、断点续传、解压缩

ps&#xff1a;本文转载自网络&#xff1a;http://ryan.easymorse.com/?p12 感谢作者 工程完整代码下载地址&#xff1a;RequestTestDownload1 可完成&#xff1a; 下载指定链接的zip压缩文件存放在Documents目录下支持断点续传显示下载进度解压到指定目录—————————…

熊仔科技Steamduino PIC18F46J50主控板 部分原理图

目录连接情况原理图实物图Proteus 8 Frofessional v8.9 SP2 从学长那嫖的&#xff0c;本来貌似是要用来做写字机器人的&#xff0c;后面学长换成Arduino UNO了。 网上找不到资料&#xff0c;用万用表简单测了测没有丝印部分的连接情况 连接情况 RD2/PMD2/RP19 USR_LED…

【51单片机快速入门指南】3.3:USART 串口通信

目录快速使用硬知识串行口相关寄存器串行口控制寄存器SCON和PCON串行口数据缓冲寄存器SBUF从机地址控制寄存器SADEN和SADDR与串行口中断相关的寄存器IE和IPH、IP串行口工作模式串行口工作模式0&#xff1a;同步移位寄存器串行口工作模式1&#xff1a;8位UART&#xff0c;波特率…

Spring JTA应用JOTM Atomikos II JOTM

上节建立了一个简单的Java Application以及所需要的数据库和数据表&#xff0c;本节将介绍JOTM在Spring中的配置。 JOTM(Java Open Transaction Manager)是ObjectWeb的一个开源JTA实现&#xff0c;本身也是开源应用程序服务器JOnAS(Java Open Application Server)的一部分&…

从包中构建瓦片服务器

SWITCH2OSM 切换到OPENSTREETMAP 丰富的数据 OpenStreetMap数据丰富而详细&#xff0c;包含与实地人相关的大量数据 - 收集的数据。 功能包括&#xff1a; 道路&#xff0c;铁路&#xff0c;水路等餐厅&#xff0c;商店&#xff0c;车站&#xff0c;自动取款机等。步行和自行车…