- 浏览: 239952 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (101)
- js (10)
- java (39)
- HTTP请求:GET与POST方法的区别(转) (1)
- Freemarker 语法规则 (1)
- AJAX级联菜单实例 (1)
- oralce (1)
- myeclipse (5)
- struts (12)
- sql存储过程基础(转) (4)
- JBPM (1)
- mysql (4)
- hibernate (3)
- ibatis (4)
- spring (4)
- 计算机技术 (1)
- nosql (1)
- sqlserver (1)
- servlet (1)
- 拦截器 (1)
- andriod 开发 (1)
- 程序员 (0)
- 多线程 (2)
- Jenkins (1)
- zk (1)
- JPA (2)
最新评论
-
zhangzh888:
怎么下载 啊 都没有看见文件
sftp处理文件 -
wx_hello:
怎么得到文件的属性呢? 比如文件的新建时间
sftp处理文件 -
HappyVeryGood:
“运行时异常(即非受控异常)自动强制执行整个逻辑工作单元的回滚 ...
事物管理,spring事物详解,spring @transactional -
skeely1234:
感谢分享,太帅了
eclipse下修改项目名导致tomcat内发布名不一致的解决方法
JSON-lib这个Java类包用于把bean,map和XML转换成JSON并能够把JSON转回成bean和DynaBean。
报错处理机制
commons-beanutils-1.8.0.jar不加这个包
java.lang.NoClassDefFoundError: org/apache/commons/beanutils/DynaBean
commons-collections.jar 不加这个包
java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ListOrderedMap
commons-lang-2.4.jar不加这个包
java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
commons-logging-1.1.1.jar不加这个包
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
ezmorph-1.0.4.jar不加这个包
java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
json-lib-2.3-jdk15.jar不加这个包
java.lang.NoClassDefFoundError: net/sf/json/JSONObject
我把这段代码拿到junit下测试 就报错了。java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException错误,查了下原因原来是少了3个包。因为我在使用json的时候只导入了json-lib-2.1.jar这个包 但是程序还需要这4个包:
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-lang-2.1.jar
ezmorph-1.0.2.jar
导入之后就发现 OK了。
下载地址:http://json-lib.sourceforge.net/
还要需要的第3方包:
org.apache.commons(3.2以上版本)
org.apache.oro
net.sf.ezmorph(ezmorph-1.0.4.jar)
nu.xom
1、List
Java代码
boolean[] boolArray = new boolean[]{true,false,true};
JSONArray jsonArray1 = JSONArray.fromObject( boolArray );
System.out.println( jsonArray1 );
// prints [true,false,true]
List list = new ArrayList();
list.add( "first" );
list.add( "second" );
JSONArray jsonArray2 = JSONArray.fromObject( list );
System.out.println( jsonArray2 );
// prints ["first","second"]
JSONArray jsonArray3 = JSONArray.fromObject( "['json','is','easy']" );
System.out.println( jsonArray3 );
// prints ["json","is","easy"]
boolean[] boolArray = new boolean[]{true,false,true};
JSONArray jsonArray1 = JSONArray.fromObject( boolArray );
System.out.println( jsonArray1 );
// prints [true,false,true]
List list = new ArrayList();
list.add( "first" );
list.add( "second" );
JSONArray jsonArray2 = JSONArray.fromObject( list );
System.out.println( jsonArray2 );
// prints ["first","second"]
JSONArray jsonArray3 = JSONArray.fromObject( "['json','is','easy']" );
System.out.println( jsonArray3 );
// prints ["json","is","easy"]
2、Map
Java代码
Map map = new HashMap();
map.put( "name", "json" );
map.put( "bool", Boolean.TRUE );
map.put( "int", new Integer(1) );
map.put( "arr", new String[]{"a","b"} );
map.put( "func", "function(i){ return this.arr[i]; }" );
JSONObject json = JSONObject.fromObject( map );
System.out.println( json );
//{"func":function(i){ return this.arr[i]; },"arr":["a","b"],"int":1,"name":"json","bool":true}
Map map = new HashMap();
map.put( "name", "json" );
map.put( "bool", Boolean.TRUE );
map.put( "int", new Integer(1) );
map.put( "arr", new String[]{"a","b"} );
map.put( "func", "function(i){ return this.arr[i]; }" );
JSONObject json = JSONObject.fromObject( map );
System.out.println( json );
//{"func":function(i){ return this.arr[i]; },"arr":["a","b"],"int":1,"name":"json","bool":true}
3、BEAN
Java代码
/**
* Bean.java
private String name = "json";
private int pojoId = 1;
private char[] options = new char[]{'a','f'};
private String func1 = "function(i){ return this.options[i]; }";
private JSONFunction func2 = new JSONFunction(new String[]{"i"},"return this.options[i];");
*/
JSONObject jsonObject = JSONObject.fromObject( new JsonBean() );
System.out.println( jsonObject );
//{"func1":function(i){ return this.options[i]; },"pojoId":1,"name":"json","options":["a","f"],"func2":function(i){ return this.options[i]; }}
/**
* Bean.java
private String name = "json";
private int pojoId = 1;
private char[] options = new char[]{'a','f'};
private String func1 = "function(i){ return this.options[i]; }";
private JSONFunction func2 = new JSONFunction(new String[]{"i"},"return this.options[i];");
*/
JSONObject jsonObject = JSONObject.fromObject( new JsonBean() );
System.out.println( jsonObject );
//{"func1":function(i){ return this.options[i]; },"pojoId":1,"name":"json","options":["a","f"],"func2":function(i){ return this.options[i]; }}
4、BEANS
Java代码
/**
* private int row ;
private int col ;
private String value ;
*
*/
List list = new ArrayList();
JsonBean2 jb1 = new JsonBean2();
jb1.setCol(1);
jb1.setRow(1);
jb1.setValue("xx");
JsonBean2 jb2 = new JsonBean2();
jb2.setCol(2);
jb2.setRow(2);
jb2.setValue("");
list.add(jb1);
list.add(jb2);
JSONArray ja = JSONArray.fromObject(list);
System.out.println( ja.toString() );
//[{"value":"xx","row":1,"col":1},{"value":"","row":2,"col":2}]
/**
* private int row ;
private int col ;
private String value ;
*
*/
List list = new ArrayList();
JsonBean2 jb1 = new JsonBean2();
jb1.setCol(1);
jb1.setRow(1);
jb1.setValue("xx");
JsonBean2 jb2 = new JsonBean2();
jb2.setCol(2);
jb2.setRow(2);
jb2.setValue("");
list.add(jb1);
list.add(jb2);
JSONArray ja = JSONArray.fromObject(list);
System.out.println( ja.toString() );
//[{"value":"xx","row":1,"col":1},{"value":"","row":2,"col":2}]
5、String to bean
Java代码
String json = "{name=\"json\",bool:true,int:1,double:2.2,func:function(a){ return a; },array:[1,2]}";
JSONObject jsonObject = JSONObject.fromString(json);
Object bean = JSONObject.toBean( jsonObject );
assertEquals( jsonObject.get( "name" ), PropertyUtils.getProperty( bean, "name" ) );
assertEquals( jsonObject.get( "bool" ), PropertyUtils.getProperty( bean, "bool" ) );
assertEquals( jsonObject.get( "int" ), PropertyUtils.getProperty( bean, "int" ) );
assertEquals( jsonObject.get( "double" ), PropertyUtils.getProperty( bean, "double" ) );
assertEquals( jsonObject.get( "func" ), PropertyUtils.getProperty( bean, "func" ) );
List expected = JSONArray.toList( jsonObject.getJSONArray( "array" ) );
assertEquals( expected, (List) PropertyUtils.getProperty( bean, "array" ) );
String json = "{name=\"json\",bool:true,int:1,double:2.2,func:function(a){ return a; },array:[1,2]}";
JSONObject jsonObject = JSONObject.fromString(json);
Object bean = JSONObject.toBean( jsonObject );
assertEquals( jsonObject.get( "name" ), PropertyUtils.getProperty( bean, "name" ) );
assertEquals( jsonObject.get( "bool" ), PropertyUtils.getProperty( bean, "bool" ) );
assertEquals( jsonObject.get( "int" ), PropertyUtils.getProperty( bean, "int" ) );
assertEquals( jsonObject.get( "double" ), PropertyUtils.getProperty( bean, "double" ) );
assertEquals( jsonObject.get( "func" ), PropertyUtils.getProperty( bean, "func" ) );
List expected = JSONArray.toList( jsonObject.getJSONArray( "array" ) );
assertEquals( expected, (List) PropertyUtils.getProperty( bean, "array" ) );
Java代码
String json = "{\"value\":\"xx\",\"row\":1,\"col\":1}";
JSONObject jsonObject = JSONObject.fromString(json);
JsonBean2 bean = (JsonBean2) JSONObject.toBean( jsonObject, JsonBean2.class );
assertEquals( jsonObject.get( "col" ),new Integer( bean.getCol()) );
assertEquals( jsonObject.get( "row" ), new Integer( bean.getRow() ) );
assertEquals( jsonObject.get( "value" ), bean.getValue() );
String json = "{\"value\":\"xx\",\"row\":1,\"col\":1}";
JSONObject jsonObject = JSONObject.fromString(json);
JsonBean2 bean = (JsonBean2) JSONObject.toBean( jsonObject, JsonBean2.class );
assertEquals( jsonObject.get( "col" ),new Integer( bean.getCol()) );
assertEquals( jsonObject.get( "row" ), new Integer( bean.getRow() ) );
assertEquals( jsonObject.get( "value" ), bean.getValue() );
6 json to xml
1)
JSONObject json = new JSONObject( true );
String xml = XMLSerializer.write( json );
<o class="object" null="true">
2)
JSONObject json = JSONObject.fromObject("{\"name\":\"json\",\"bool\":true,\"int\":1}");
String xml = XMLSerializer.write( json );
<o class="object">
<name type="string">json</name>
<bool type="boolean">true</bool>
<int type="number">1</int>
</o>
<o class="object">
<name type="string">json</name>
<bool type="boolean">true</bool>
<int type="number">1</int>
</o>
3)
JSONArray json = JSONArray.fromObject("[1,2,3]");
String xml = XMLSerializer.write( json );
<a class="array">
<e type="number">1</e>
<e type="number">2</e>
<e type="number">3</e>
</a>
7 、xml to json
<a class="array">
<e type="function" params="i,j">
return matrix[i][j];
</e>
</a>
<a class="array">
<e type="function" params="i,j">
return matrix[i][j];
</e>
</a>
JSONArray json = (JSONArray) XMLSerializer.read( xml );
System.out.println( json );
// prints [function(i,j){ return matrix[i][j]; }]
在Java中加上这几个包
实例:
import java.io.IOException;
import java.util.ArrayList;
import java.sql.Date;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import aa.JsonBean2;
public class main extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List list = new ArrayList();
JsonBean2 jb1 = new JsonBean2();
jb1.setA(1);
jb1.setB("丁龙飞");
System.out.println("*****123");
Date c=new Date(100,9,10);
String s=c.toString();
System.out.println(s+"33333");
jb1.setC(s);
JsonBean2 jb2 = new JsonBean2();
jb2.setA(1);
jb2.setB("b");
jb2.setC(s);
list.add(jb1);
list.add(jb2);
JSONObject obj= JSONObject.fromObject(jb1);
System.out.println(obj.toString()+"*****123");
JSONArray ja = JSONArray.fromObject(list);
System.out.println(ja.toString()+"-------------");
System.out.println("asdfasdf");
// List list=new ArrayList();
String a="var a=[[1,{text:'ext'},{text:'q'},1,'132','321','2008-01-01 12:01:01'],[2,{text:'ext'},{text:'w'},2,'132','321','2008-01-01 12:01:01']]";
response.getWriter().print(a);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
报错处理机制
commons-beanutils-1.8.0.jar不加这个包
java.lang.NoClassDefFoundError: org/apache/commons/beanutils/DynaBean
commons-collections.jar 不加这个包
java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ListOrderedMap
commons-lang-2.4.jar不加这个包
java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
commons-logging-1.1.1.jar不加这个包
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
ezmorph-1.0.4.jar不加这个包
java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
json-lib-2.3-jdk15.jar不加这个包
java.lang.NoClassDefFoundError: net/sf/json/JSONObject
我把这段代码拿到junit下测试 就报错了。java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException错误,查了下原因原来是少了3个包。因为我在使用json的时候只导入了json-lib-2.1.jar这个包 但是程序还需要这4个包:
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-lang-2.1.jar
ezmorph-1.0.2.jar
导入之后就发现 OK了。
下载地址:http://json-lib.sourceforge.net/
还要需要的第3方包:
org.apache.commons(3.2以上版本)
org.apache.oro
net.sf.ezmorph(ezmorph-1.0.4.jar)
nu.xom
1、List
Java代码
boolean[] boolArray = new boolean[]{true,false,true};
JSONArray jsonArray1 = JSONArray.fromObject( boolArray );
System.out.println( jsonArray1 );
// prints [true,false,true]
List list = new ArrayList();
list.add( "first" );
list.add( "second" );
JSONArray jsonArray2 = JSONArray.fromObject( list );
System.out.println( jsonArray2 );
// prints ["first","second"]
JSONArray jsonArray3 = JSONArray.fromObject( "['json','is','easy']" );
System.out.println( jsonArray3 );
// prints ["json","is","easy"]
boolean[] boolArray = new boolean[]{true,false,true};
JSONArray jsonArray1 = JSONArray.fromObject( boolArray );
System.out.println( jsonArray1 );
// prints [true,false,true]
List list = new ArrayList();
list.add( "first" );
list.add( "second" );
JSONArray jsonArray2 = JSONArray.fromObject( list );
System.out.println( jsonArray2 );
// prints ["first","second"]
JSONArray jsonArray3 = JSONArray.fromObject( "['json','is','easy']" );
System.out.println( jsonArray3 );
// prints ["json","is","easy"]
2、Map
Java代码
Map map = new HashMap();
map.put( "name", "json" );
map.put( "bool", Boolean.TRUE );
map.put( "int", new Integer(1) );
map.put( "arr", new String[]{"a","b"} );
map.put( "func", "function(i){ return this.arr[i]; }" );
JSONObject json = JSONObject.fromObject( map );
System.out.println( json );
//{"func":function(i){ return this.arr[i]; },"arr":["a","b"],"int":1,"name":"json","bool":true}
Map map = new HashMap();
map.put( "name", "json" );
map.put( "bool", Boolean.TRUE );
map.put( "int", new Integer(1) );
map.put( "arr", new String[]{"a","b"} );
map.put( "func", "function(i){ return this.arr[i]; }" );
JSONObject json = JSONObject.fromObject( map );
System.out.println( json );
//{"func":function(i){ return this.arr[i]; },"arr":["a","b"],"int":1,"name":"json","bool":true}
3、BEAN
Java代码
/**
* Bean.java
private String name = "json";
private int pojoId = 1;
private char[] options = new char[]{'a','f'};
private String func1 = "function(i){ return this.options[i]; }";
private JSONFunction func2 = new JSONFunction(new String[]{"i"},"return this.options[i];");
*/
JSONObject jsonObject = JSONObject.fromObject( new JsonBean() );
System.out.println( jsonObject );
//{"func1":function(i){ return this.options[i]; },"pojoId":1,"name":"json","options":["a","f"],"func2":function(i){ return this.options[i]; }}
/**
* Bean.java
private String name = "json";
private int pojoId = 1;
private char[] options = new char[]{'a','f'};
private String func1 = "function(i){ return this.options[i]; }";
private JSONFunction func2 = new JSONFunction(new String[]{"i"},"return this.options[i];");
*/
JSONObject jsonObject = JSONObject.fromObject( new JsonBean() );
System.out.println( jsonObject );
//{"func1":function(i){ return this.options[i]; },"pojoId":1,"name":"json","options":["a","f"],"func2":function(i){ return this.options[i]; }}
4、BEANS
Java代码
/**
* private int row ;
private int col ;
private String value ;
*
*/
List list = new ArrayList();
JsonBean2 jb1 = new JsonBean2();
jb1.setCol(1);
jb1.setRow(1);
jb1.setValue("xx");
JsonBean2 jb2 = new JsonBean2();
jb2.setCol(2);
jb2.setRow(2);
jb2.setValue("");
list.add(jb1);
list.add(jb2);
JSONArray ja = JSONArray.fromObject(list);
System.out.println( ja.toString() );
//[{"value":"xx","row":1,"col":1},{"value":"","row":2,"col":2}]
/**
* private int row ;
private int col ;
private String value ;
*
*/
List list = new ArrayList();
JsonBean2 jb1 = new JsonBean2();
jb1.setCol(1);
jb1.setRow(1);
jb1.setValue("xx");
JsonBean2 jb2 = new JsonBean2();
jb2.setCol(2);
jb2.setRow(2);
jb2.setValue("");
list.add(jb1);
list.add(jb2);
JSONArray ja = JSONArray.fromObject(list);
System.out.println( ja.toString() );
//[{"value":"xx","row":1,"col":1},{"value":"","row":2,"col":2}]
5、String to bean
Java代码
String json = "{name=\"json\",bool:true,int:1,double:2.2,func:function(a){ return a; },array:[1,2]}";
JSONObject jsonObject = JSONObject.fromString(json);
Object bean = JSONObject.toBean( jsonObject );
assertEquals( jsonObject.get( "name" ), PropertyUtils.getProperty( bean, "name" ) );
assertEquals( jsonObject.get( "bool" ), PropertyUtils.getProperty( bean, "bool" ) );
assertEquals( jsonObject.get( "int" ), PropertyUtils.getProperty( bean, "int" ) );
assertEquals( jsonObject.get( "double" ), PropertyUtils.getProperty( bean, "double" ) );
assertEquals( jsonObject.get( "func" ), PropertyUtils.getProperty( bean, "func" ) );
List expected = JSONArray.toList( jsonObject.getJSONArray( "array" ) );
assertEquals( expected, (List) PropertyUtils.getProperty( bean, "array" ) );
String json = "{name=\"json\",bool:true,int:1,double:2.2,func:function(a){ return a; },array:[1,2]}";
JSONObject jsonObject = JSONObject.fromString(json);
Object bean = JSONObject.toBean( jsonObject );
assertEquals( jsonObject.get( "name" ), PropertyUtils.getProperty( bean, "name" ) );
assertEquals( jsonObject.get( "bool" ), PropertyUtils.getProperty( bean, "bool" ) );
assertEquals( jsonObject.get( "int" ), PropertyUtils.getProperty( bean, "int" ) );
assertEquals( jsonObject.get( "double" ), PropertyUtils.getProperty( bean, "double" ) );
assertEquals( jsonObject.get( "func" ), PropertyUtils.getProperty( bean, "func" ) );
List expected = JSONArray.toList( jsonObject.getJSONArray( "array" ) );
assertEquals( expected, (List) PropertyUtils.getProperty( bean, "array" ) );
Java代码
String json = "{\"value\":\"xx\",\"row\":1,\"col\":1}";
JSONObject jsonObject = JSONObject.fromString(json);
JsonBean2 bean = (JsonBean2) JSONObject.toBean( jsonObject, JsonBean2.class );
assertEquals( jsonObject.get( "col" ),new Integer( bean.getCol()) );
assertEquals( jsonObject.get( "row" ), new Integer( bean.getRow() ) );
assertEquals( jsonObject.get( "value" ), bean.getValue() );
String json = "{\"value\":\"xx\",\"row\":1,\"col\":1}";
JSONObject jsonObject = JSONObject.fromString(json);
JsonBean2 bean = (JsonBean2) JSONObject.toBean( jsonObject, JsonBean2.class );
assertEquals( jsonObject.get( "col" ),new Integer( bean.getCol()) );
assertEquals( jsonObject.get( "row" ), new Integer( bean.getRow() ) );
assertEquals( jsonObject.get( "value" ), bean.getValue() );
6 json to xml
1)
JSONObject json = new JSONObject( true );
String xml = XMLSerializer.write( json );
<o class="object" null="true">
2)
JSONObject json = JSONObject.fromObject("{\"name\":\"json\",\"bool\":true,\"int\":1}");
String xml = XMLSerializer.write( json );
<o class="object">
<name type="string">json</name>
<bool type="boolean">true</bool>
<int type="number">1</int>
</o>
<o class="object">
<name type="string">json</name>
<bool type="boolean">true</bool>
<int type="number">1</int>
</o>
3)
JSONArray json = JSONArray.fromObject("[1,2,3]");
String xml = XMLSerializer.write( json );
<a class="array">
<e type="number">1</e>
<e type="number">2</e>
<e type="number">3</e>
</a>
7 、xml to json
<a class="array">
<e type="function" params="i,j">
return matrix[i][j];
</e>
</a>
<a class="array">
<e type="function" params="i,j">
return matrix[i][j];
</e>
</a>
JSONArray json = (JSONArray) XMLSerializer.read( xml );
System.out.println( json );
// prints [function(i,j){ return matrix[i][j]; }]
在Java中加上这几个包
实例:
import java.io.IOException;
import java.util.ArrayList;
import java.sql.Date;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import aa.JsonBean2;
public class main extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List list = new ArrayList();
JsonBean2 jb1 = new JsonBean2();
jb1.setA(1);
jb1.setB("丁龙飞");
System.out.println("*****123");
Date c=new Date(100,9,10);
String s=c.toString();
System.out.println(s+"33333");
jb1.setC(s);
JsonBean2 jb2 = new JsonBean2();
jb2.setA(1);
jb2.setB("b");
jb2.setC(s);
list.add(jb1);
list.add(jb2);
JSONObject obj= JSONObject.fromObject(jb1);
System.out.println(obj.toString()+"*****123");
JSONArray ja = JSONArray.fromObject(list);
System.out.println(ja.toString()+"-------------");
System.out.println("asdfasdf");
// List list=new ArrayList();
String a="var a=[[1,{text:'ext'},{text:'q'},1,'132','321','2008-01-01 12:01:01'],[2,{text:'ext'},{text:'w'},2,'132','321','2008-01-01 12:01:01']]";
response.getWriter().print(a);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
- json.rar (1 KB)
- 下载次数: 4
发表评论
-
习惯的开发错误
2014-09-09 17:25 478在一个包的下面 创建一个test.java 文件 这样一个小 ... -
得到指定年份的所有周末
2014-08-20 18:18 1210/** * 得到指定年份的所有周末 */ publi ... -
对对字符串可能出现报空指针的小问题
2014-04-14 14:42 890今天很是郁闷啊,遇到一个基础的问题比对字符串的两种写法: ... -
Java 单例模式详解(转)
2014-03-26 16:52 831概念: java中单例 ... -
往文件里写入字符串
2014-01-20 13:52 1151package ab; import java.io.Bu ... -
Java数组,去掉重复值、增加、删除数组元素
2014-01-02 14:18 5172import java.util.List; import ... -
java定时器的使用(Timer)
2013-10-14 16:42 2446java定时器的使用(Timer) 2008-02-14 13 ... -
JSch - Java实现的SFTP(文件上传详解篇)(转)
2013-10-14 16:40 3445JSch是Java Secure Channel的缩写。JSc ... -
jvm
2013-09-30 15:03 775网上看到一位javaeye的同志写的文章,感觉总结的比较好,虽 ... -
sftp处理文件
2013-09-30 15:02 8110最近工作涉及sftp处理文件,写了个工具类,代码已经测试。请需 ... -
java BigDecimal的使用和四舍五入及格式规范(精准数据)
2013-06-17 15:37 21579• Java中的简单浮点数类型float和double不能够进 ... -
servlet拦截器代码
2013-03-29 13:45 22521- 实现Servlet.Filter接口 public cl ... -
session 超时的时间设置
2013-03-22 14:47 979为单个Web应用 配置超时时间可以在web.xml中使用< ... -
Calendar 获取日期
2013-01-23 10:44 1336Calendar 获取日期 如果想得到某个星期几是什么日期, ... -
JAVA帮助文档全系列
2013-01-05 11:02 0JAVA帮助文档全系列 JDK1.5 JDK1.6 JD ... -
Cannot create a server using the selected type
2012-08-27 11:02 0eclipse中安装tomcat服务器,报错" Ca ... -
线程池(jdk实现)
2012-07-10 15:01 0Sun在Java5中,对Java线程的类库做了大量的扩展,其中 ... -
遍历集合
2012-06-26 17:28 1075* * To change this template, c ... -
(转)Java 序列化
2012-06-26 14:55 1955当我们需要序列化一个J ... -
权限控制的发散性思维
2012-06-15 17:31 996权限控制的讨论 http://www.iteye.com ...
相关推荐
`fromObject`和`toBean`方法分别实现了从Java对象到JSON对象和从JSON对象到Java对象的转换,这在处理JSON数据和Java业务对象间的数据交换时非常有用。 在处理JSON数组时,`net.sf.json.JSONArray`类提供了类似的...
在本案例中,Spring将作为整个应用的框架,管理和配置我们的组件,包括Mybatis的数据访问层。 然后是`Mybatis`,它是一个轻量级的持久层框架,与传统的ORM框架相比,Mybatis更加灵活。Mybatis允许开发者编写SQL语句...
然而,解析JSON数据时可能会遇到各种报错情况。本篇将深入探讨一个具体的Java解析JSON数据时报错问题及其解决方案。 一、问题背景 在实际项目测试阶段,测试人员发现后台日志频繁出现JSON解析错误。错误信息提示,...
```java Gson gson = new Gson(); MyResponse response = gson.fromJson(inputStreamReader, MyResponse.class); ``` 为了提高性能和简化代码,可以考虑使用第三方库如Retrofit,它提供了更高级别的抽象,使网络...
在本案例中,可能使用了JSONP(JSON with Padding)来解决跨域问题,因为JSONP是一种在不支持CORS的旧版浏览器中实现跨域请求的常见方法。 JSONP的工作原理是利用`<script>`标签不受同源策略限制的特点,通过动态...
Java I/O(输入/输出)提供了读取和写入文件的基本机制。在文件转发的过程中,我们需要使用Java I/O来处理文件的读写。 ##### 6. UUID类 UUID类提供了一种生成全局唯一标识符的方式。在文件上传场景中,为了避免...
综上所述,宇视科技门禁系统对外接口文档提供了丰富的接口使用指南和应用场景案例,不仅覆盖了从基础概念到高级应用的各个方面,还针对常见问题给出了具体的解决策略。通过对这些知识点的学习与实践,可以帮助用户更...
如案例中提到的,修改了模型类并添加了带参数的构造函数后,如果未提供无参构造函数,Spring MVC可能无法正确地实例化对象。这是因为Spring MVC依赖于默认的无参构造函数来创建对象并填充来自请求的数据。 解决...
1.5 程序报错处理:对常见的Python程序错误类型进行分析,如缩进错误、引包错误、编码错误等。 2. Django框架 2.1 Django开发环境:讲解在Windows和Ubuntu下安装Django的方法。 2.2 Django入门:从创建项目与...
开发者需要熟悉Java或Kotlin语言,这是Android应用的主要编程语言。此外,对于大型项目,理解模块化和组件化开发思路也非常重要,这有助于代码的管理和维护。 描述中的"博文链接:...
- 统一异常处理机制,提高用户体验。 - **单元测试**: - 使用JUnit和Mockito进行单元测试。 #### 五、实战案例分析 - **案例背景**:本教程以一个电商平台项目为例,涵盖商品管理、订单处理等模块。 - **需求...
对于集群状态为黄色时并发插入数据报错的情况,也有相应的处理方法和建议。 在文档最后,提到了Elasticsearch的学习资料和参考资料,以及一些名词的定义和缩略语说明。这些信息对于开发者和使用者理解Elasticsearch...
在“传智书城项目实践”中,我们探讨的是一个实际的软件开发案例,它涉及到构建和维护一个图书销售或管理平台。这个项目可能涵盖了多种技术栈和开发流程,旨在帮助学习者提升其在真实工作环境中的应用能力。在描述中...
ElasticSearch运行在Java虚拟机(JVM)之上,因此JVM配置非常重要。主要关注点包括堆内存大小、垃圾回收策略等。 #### 五、源码分析 **6.1. 使用Guice进行依赖注入与模块化系统** ElasticSearch使用Guice框架来管理...
在面对Python程序报错时,本书建议读者不要慌张,给出了几种常见的错误类型及其解决方法,比如缩进错误、引包错误、编码错误等,并提倡学会分析错误来提高解决问题的能力。 书中第二章开始引入Django框架的入门知识...