- 浏览: 592001 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
zhanghao1785:
jQuery jqGrid中ColModel的参数大全 -
haiyangyiba:
在实际应用中,回车提交一般需要注意的是,多次回车之间的间隔,换 ...
回车自动提交 -
fengkuangxiao6:
快捷键能写的这么详细,太棒了!
Eclipse中10个最有用的快捷键组合 -
Frank_Sun:
我的jdk版本是1.6.0.29,在finally中加retu ...
try catch finally与return的执行顺序 -
jueyue:
这个注解可以搞吗,感觉还不如放在前台
struts2校验(二):声明式验证(基于xml配置验证)(1)
控制台打印异常如下:
2013-05-16 17:22:26 com.tianque.core.struts.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:28)-[ERROR] 拦截到异常:org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException -(:28)
2013-05-16 17:22:26 com.tianque.core.struts.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:29)-[ERROR] org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.write(JSONWriter.java:99)
at org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:112)
at org.apache.struts2.json.JSONResult.execute(JSONResult.java:198)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
at com.opensymphony.xwork2.interceptor.LoggingInterceptor.intercept(LoggingInterceptor.java:56)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.tianque.core.struts.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:26)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.tianque.core.web.filter.ClearThreadVariable.doFilter(ClearThreadVariable.java:25)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.servlet.UserAgentFilter.doFilter(UserAgentFilter.java:78)
at org.mortbay.servlet.GzipFilter.doFilter(GzipFilter.java:131)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.array(JSONWriter.java:418)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:155)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
... 98 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:227)
... 105 more
Caused by: java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1070)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:859)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:852)
at java.text.DateFormat.format(DateFormat.java:316)
at com.tianque.domain.vo.IssueViewObject.getOccurDateString(IssueViewObject.java:401)
... 110 more
仔细看最后一段,不可小觑:Caused by: java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1070)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:859)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:852)
at java.text.DateFormat.format(DateFormat.java:316)
at com.tianque.domain.vo.IssueViewObject.getOccurDateString(IssueViewObject.java:401)
... 110 more
IssueViewObject.java
public class IssueViewObject implements Serializable {
……………………
……………………
public String getOccurDateString() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
String nowTime = format.format(this.occurDate);
String now = nowTime.substring(nowTime.length() - 2, nowTime.length());
String time = "凌晨";
if (6 <= Integer.parseInt(now) && Integer.parseInt(now) < 12) {
time = "上午";
} else if (12 <= Integer.parseInt(now) && Integer.parseInt(now) < 18) {
time = "下午";
} else if (18 <= Integer.parseInt(now) && Integer.parseInt(now) < 24) {
time = "晚上";
}
return nowTime.substring(0, nowTime.length() - 2) + " " + time;
}
}
debug模式启动,根据控制台报错IssueViewObject.getOccurDateString(IssueViewObject.java:401)定位getOccurDateString() 中this.occurDate,发现它是null,解决方法
public class IssueViewObject implements Serializable {
……………………
……………………
public String getOccurDateString() {
if (null == occurDate)
return null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
String nowTime = format.format(this.occurDate);
String now = nowTime.substring(nowTime.length() - 2, nowTime.length());
String time = "凌晨";
if (6 <= Integer.parseInt(now) && Integer.parseInt(now) < 12) {
time = "上午";
} else if (12 <= Integer.parseInt(now) && Integer.parseInt(now) < 18) {
time = "下午";
} else if (18 <= Integer.parseInt(now) && Integer.parseInt(now) < 24) {
time = "晚上";
}
return nowTime.substring(0, nowTime.length() - 2) + " " + time;
}
}
2013-05-16 17:22:26 com.tianque.core.struts.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:28)-[ERROR] 拦截到异常:org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException -(:28)
2013-05-16 17:22:26 com.tianque.core.struts.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:29)-[ERROR] org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.write(JSONWriter.java:99)
at org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:112)
at org.apache.struts2.json.JSONResult.execute(JSONResult.java:198)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
at com.opensymphony.xwork2.interceptor.LoggingInterceptor.intercept(LoggingInterceptor.java:56)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.tianque.core.struts.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:26)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.tianque.core.web.filter.ClearThreadVariable.doFilter(ClearThreadVariable.java:25)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.servlet.UserAgentFilter.doFilter(UserAgentFilter.java:78)
at org.mortbay.servlet.GzipFilter.doFilter(GzipFilter.java:131)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.array(JSONWriter.java:418)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:155)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
... 98 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:227)
... 105 more
Caused by: java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1070)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:859)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:852)
at java.text.DateFormat.format(DateFormat.java:316)
at com.tianque.domain.vo.IssueViewObject.getOccurDateString(IssueViewObject.java:401)
... 110 more
仔细看最后一段,不可小觑:Caused by: java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1070)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:859)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:852)
at java.text.DateFormat.format(DateFormat.java:316)
at com.tianque.domain.vo.IssueViewObject.getOccurDateString(IssueViewObject.java:401)
... 110 more
IssueViewObject.java
public class IssueViewObject implements Serializable {
……………………
……………………
public String getOccurDateString() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
String nowTime = format.format(this.occurDate);
String now = nowTime.substring(nowTime.length() - 2, nowTime.length());
String time = "凌晨";
if (6 <= Integer.parseInt(now) && Integer.parseInt(now) < 12) {
time = "上午";
} else if (12 <= Integer.parseInt(now) && Integer.parseInt(now) < 18) {
time = "下午";
} else if (18 <= Integer.parseInt(now) && Integer.parseInt(now) < 24) {
time = "晚上";
}
return nowTime.substring(0, nowTime.length() - 2) + " " + time;
}
}
debug模式启动,根据控制台报错IssueViewObject.getOccurDateString(IssueViewObject.java:401)定位getOccurDateString() 中this.occurDate,发现它是null,解决方法
public class IssueViewObject implements Serializable {
……………………
……………………
public String getOccurDateString() {
if (null == occurDate)
return null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
String nowTime = format.format(this.occurDate);
String now = nowTime.substring(nowTime.length() - 2, nowTime.length());
String time = "凌晨";
if (6 <= Integer.parseInt(now) && Integer.parseInt(now) < 12) {
time = "上午";
} else if (12 <= Integer.parseInt(now) && Integer.parseInt(now) < 18) {
time = "下午";
} else if (18 <= Integer.parseInt(now) && Integer.parseInt(now) < 24) {
time = "晚上";
}
return nowTime.substring(0, nowTime.length() - 2) + " " + time;
}
}
发表评论
-
action成功执行到success,但是前台却进入了ajax的error分支
2014-02-13 17:08 1432zlxx.jsp $.ajax({ ... -
Port busy 8009 java.net.BindException: Address already in use: JVM_Bind
2013-05-30 17:26 5623Port busy 8009 java.net.BindExc ... -
包冲突java.lang.NoSuchMethodError: XXXXX
2013-05-30 17:23 1267解决办法:把相同包低版本的去掉 -
hibernate程序save成功了,但是表里没有插入
2013-05-30 17:20 686如果你save了对象,那么hibernate并没有把数据存入数 ... -
Io 异常: The Network Adapter could not establish the connection
2013-05-30 17:17 1063我当时的改正方法:1.ping ip 2.telnet ... -
struts2标签不显示Label的解决方法
2013-05-29 17:16 1190struts2标签不显示Label的解决方法 最近发现st ... -
异常The Struts dispatcher cannot be found.this is usually caused by using struts
2013-05-29 16:45 13081.http staus 500 The Struts dis ... -
Could not set property 'supervisionState' to value 'null'
2012-07-31 14:39 1931异常: 我的查询方法: 对应的vo类[img] ... -
异常:Index: 1, Size: 1
2012-07-24 15:12 2338所报异常如下图: 这是数组越界异常,原因是我的程序如下: ... -
java.sql.SQLException: 列名无效
2012-07-17 16:46 4215seachIssueNew.xml <select ... -
error:for SQL []; SQL state [null]; error code [0]
2012-06-25 10:49 18655org.quartz.SchedulerException: ... -
异常:Error: executeQueryForObject returned too many results.
2012-06-25 09:34 7342QueryForObject方法返回的是一个对象,如果有 ... -
ORA-01747: user.table.column, table.column 或列说明无效
2012-05-21 17:22 85765ORA-01747: user.table.column, t ... -
could not autowired field or No unique been of type
2012-05-15 14:08 1223初步判断是dao注入了两次,但检查发现没有,粗心将dao写 ... -
java.lang.NullPointerException
2012-05-15 14:08 1182由于使用spring控制反转来自动生成javaBean, ... -
No SqlMapClient specified
2012-05-14 10:53 1413异常:No SqlMapClient specified ... -
ibatis表列名和对象属性名称要对应一致
2012-05-14 10:41 1713对应的domain类: 注意:EMP_ID是数据库表的 ... -
uncategorized SQLException
2012-05-14 10:24 2038原因:Domain中status属性声明为int类型(基本 ... -
not found 302
2012-05-14 09:52 4652not found 302 :跳转不到指定url,通常是过滤器 ... -
异常2
2012-05-15 14:08 1035<update id="updateUnset ...
相关推荐
`org.json`库的核心类主要包括`JSONObject`、`JSONArray`、`JSONString`、`JSONTokener`和`JSONException`等。以下将详细阐述这些类的功能和使用方法: 1. **JSONObject**: `JSONObject`是表示JSON对象的类,它以...
在编程过程中,我们可能会遇到各种异常,其中"JSONException: expect ‘:’ at 0, actual =" 是一个典型的Fastjson库在解析JSON时抛出的异常。Fastjson是阿里巴巴提供的一款高性能的JSON解析和生成库,它广泛应用于...
3. **JSONException**: 这是处理JSON时抛出的异常类,通常当JSON格式错误或者解析出错时会抛出。 4. **JSONStringer**: 提供了一种构建JSON字符串的方法,通过调用一系列的方法,可以构造出复杂的JSON结构。 5. **...
6. **错误处理**:`JSONException` 是`org.json`库中的异常类,当解析JSON数据时遇到问题(如格式错误、键不存在等)时会抛出此异常。在使用`get()`、`opt()`等方法时,应捕获并处理此类异常。 7. **其他辅助类**:...
2. 引用包:在代码中,通过`import org.json.JSONObject;`引入所需的类。 3. 使用示例:创建一个简单的`JSONObject`并进行操作。 ```java import org.json.JSONObject; public class JsonExample { public ...
4. **JSONException**:当JSON操作过程中出现错误时抛出的异常,比如解析错误、类型不匹配等。 5. **JSONStringer** 和 **JSONWriter**:这两个类用于构建复杂的JSON结构,提供了更灵活的API来构造JSON文本。 6. *...
5. **JSONException**:当JSON操作出现错误时抛出的异常,如解析错误、无效的JSON格式等。 在2017.10.18这个版本中,可能包含了对JSON规范的更新、性能优化、bug修复以及新功能的添加。具体更新内容可以通过查看该...
`org.json.JSONObject`是Java编程语言中用于处理JSON(JavaScript Object Notation)数据的一个轻量级库。这个库由Mozilla Public License提供,广泛应用于需要在Java应用中进行JSON解析、生成和操作的场景。JSON是...
org.json.JSONObject的6个jar包 commons-beanutils;commons-collections;commons-lang;commons-logging;ezmorph;json-lib
- `JSONException`:在处理JSON过程中抛出的异常,例如语法错误或数据不匹配。 - `JSONTokener`:用于解析JSON字符串,提供`next()`和`back()`等方法来移动解析位置。 - `XML`:类,提供了将XML转换为JSON的功能...
1. 错误处理:在进行JSON操作时,需捕获JSONException异常,确保程序的健壮性。 2. 性能考虑:org.json库虽然轻量,但在处理大量数据时性能可能不如Gson或Jackson库。根据项目需求选择合适的库。 3. 版本差异:题目...
`org.json`库不仅有`JSONObject`,还有其他类,如`JSONArray`用于表示JSON数组,`JSONException`用于处理与JSON相关的异常,`JSONStringer`和`JSONWriter`则提供更高效的JSON序列化方式。此外,`JSONArray`和`...
标题中的"org json.rar"可能是指一个包含有关“org.json”库的压缩文件,这个库在Java编程语言中被广泛用于处理JSON(JavaScript Object Notation)数据。JSON是一种轻量级的数据交换格式,易于人阅读和编写,同时也...
4. **JSONException**:当处理JSON时发生错误时抛出的异常类。 5. **JSONTokener**:用于解析JSON字符串的类,可以将JSON文本转换为JSON对象或数组。 6. **JSONWriter**:提供了更高级的JSON输出方法,用于生成格式...
org.json全部源代码 1、CDL.java 2、Cookie.java 3、CookieList.java 4、HTTP.java 5、HTTPTokener.java 6、JSONArray.java 7、JSONException.java 8、JSONML.java 9、JSONObject.java 10、JSONString.java 11、...
3. **JSONException**:这是处理`org.json`库时可能出现的异常,通常在解析错误或数据格式不正确时抛出。 4. **JSONStringer**:提供了一个流式API来构建JSON结构,适合生成复杂的JSON字符串。 5. **JSONTokener**...
此外,还有`JSONException`异常类用于处理解析和序列化过程中出现的错误,以及`JSONStringer`和`JSONWriter`用于更精细的JSON构建。 在给定的压缩包文件中,除了`json.jar`之外,还包含了其他几个与JSON处理相关的...
6. **JSONException**: 当JSON处理过程中发生错误时抛出的异常。 7. **JSONWriter**: 类似于JSONStringer,提供了一种构造JSON文本的方式,但提供了更细粒度的控制,例如缩进和新行。 源代码和Javadoc的包含意味着...