在项目中遇到这种下标越界的问题怎么改!
在项目中遇到这种下标越界的问题怎么改!
浏览器报错如下:
java.lang.IndexOutOfBoundsException: Index: 0
at java.util.Collections$EmptyList.get(Collections.java:2976)
at cn.com.gwypx.jwgl.action.staff.RegisterScoreTimeAction.edit(RegisterScoreTimeAction.java:36)
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 ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:892)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1294)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)
打桩测试action红字部分就没有执行了:
public String edit()
{
List list = TimeService.find();
Map map = (Map) list.get(0);
Integer id = (Integer) map.get("id");
if (!empty(id))
{
scoreTime = TimeService.get(id);
}
if (!empty(scoreTime))
{
request.setAttribute("scoreTime", scoreTime);
}
return "input";
}
public String save()
{
// 首先判断是否存在设置的数据
List list = TimeService.find();
if (list.size() <= 0)
{
// 创建时间
scoreTime.setCreat_date(new Date());
sql:
/*DDL 信息*/------------
CREATE TABLE `tb_register_score_time` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`start_time` date NOT NULL,
`end_time` date NOT NULL,
`status` int(11) DEFAULT '1',
`creat_date` date DEFAULT NULL,
`creat_staff` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8