SSH里,实体类有日期字段,我设置的是Calendar类型。然后用注解加上注解,如
@Column(name = "fasjsx")
private Calendar caseHpUpLmt;
getter/setter...查询的时候,使用getHibernateTemplate().find(queryString),如:
String queryString = "from CaseInfo";
List list = getHibernateTemplate().find(queryString);
查询出实体后,发现所有的字段变成了java.util.GregorianCalendar类型!将查询结果返回给前台的时候,我的做法如下:JSONObject object = new JSONObject();
object.put("success", true);
object.put("caseInfo", caseInfo);
try{
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8");
PrintWriter pw = response.getWriter();
pw.print(object.toString());
pw.close();
}catch (Exception e) {
ret = false;
e.printStackTrace();
}控制台报出:[net.sf.json.JSONObject]-[INFO] Property 'actualMaximum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'actualMinimum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'greatestMinimum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'leastMaximum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'maximum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'minimum' of class java.util.GregorianCalendar has no read method. SKIPPED(关于上面的warning,都说java内省机制,缺少getset导致的,但我的实体bean里真有getset呀)最后,前台就显示不了日期字段值了。具体的流程背景就这样了。实体类有Calendar类型的字段,如何做JSON转换?请各位帮帮忙,谢谢咯
@Column(name = "fasjsx")
private Calendar caseHpUpLmt;
getter/setter...查询的时候,使用getHibernateTemplate().find(queryString),如:
String queryString = "from CaseInfo";
List list = getHibernateTemplate().find(queryString);
查询出实体后,发现所有的字段变成了java.util.GregorianCalendar类型!将查询结果返回给前台的时候,我的做法如下:JSONObject object = new JSONObject();
object.put("success", true);
object.put("caseInfo", caseInfo);
try{
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8");
PrintWriter pw = response.getWriter();
pw.print(object.toString());
pw.close();
}catch (Exception e) {
ret = false;
e.printStackTrace();
}控制台报出:[net.sf.json.JSONObject]-[INFO] Property 'actualMaximum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'actualMinimum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'greatestMinimum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'leastMaximum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'maximum' of class java.util.GregorianCalendar has no read method. SKIPPED
[net.sf.json.JSONObject]-[INFO] Property 'minimum' of class java.util.GregorianCalendar has no read method. SKIPPED(关于上面的warning,都说java内省机制,缺少getset导致的,但我的实体bean里真有getset呀)最后,前台就显示不了日期字段值了。具体的流程背景就这样了。实体类有Calendar类型的字段,如何做JSON转换?请各位帮帮忙,谢谢咯
解决方案 »
- org.eclipse.birt.core.exception.BirtException: Can not startup the OSGI framewor
- 关于看JDK源码的问题
- lomboz小问题
- 求《精通Java网络编程(第二版)》
- 求助,socket与jms接口
- sessionbean+hibernate中,是否bean中每个方法都新建一个session呢?
- 今天从.net转向JAVA,请大家谈谈些方法。推荐些学习站点及学习资料。先谢!
- J2EE高手请进!看看菜鸟们的心声!!!
- 【ligerui】使用$("form").ligerForm()后select中的内容不显示
- SSH中用DetachedCriteria查询问题。
- 请教EJB连接数据库连接池问题
- js传递bean参数,找不到action~~
如果不用Calendar类型而是用String类型,那到没什么问题。哎