报错原信息:
SG-UAP :ERROR RestExceptionResolver:141 - java.lang.StringIndexOutOfBounds
Exception: String index out of range: -6
at java.lang.String.substring(String.java:1937)
at java.lang.String.substring(String.java:1904)
at com.sgcc.uap.rest.annotation.processors.QueryRequestParamArgumentResolver.resolveArgument(QueryRequestParamArgumentResolver.java:72)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:75)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:156)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at com.sgcc.uap.kernel.spring.ModuleWebDispatcher.doDispatch(ModuleWebDispatcher.java:211)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:790)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
at com.sgcc.uap.kernel.web.adaptor.ModuleServletAdaptor.service(ModuleServletAdaptor.java:119)
问题分析:
- 首先这个是UAP的Spring的REST异常, 通常是 REST输入的数据格式不正确]。
- 再根据Exception: String index out of range: -6 索引值越界,判断是有数据输入越界, 很有可能是空的间隔符造成的。
- 之后查找报错使用的REST路径和JS 方法,发现Json有错误和异常的可能性。
1 function _dropDown_changed(){ 2 var restClient = new mx.rpc.RESTClient(); 3 var data ={"":""}; 4 var url = config_index.mappath("~/rest/config/getTable"); 5 var ret = ""; 6 restClient.post(url, data, function(ret){ 7 _ConfigDropEdt.setItems(eval(ret)); 8 }); 9 }
修改之后,不在报错,功能也能使用了。
1 function _dropDown_changed(){ 2 var restClient = new mx.rpc.RESTClient(); 3 var data = "";//取消原先的{"":""}; 4 var url = config_index.mappath("~/rest/config/getTable"); 5 var ret = ""; 6 restClient.post(url, data, function(ret){ 7 _ConfigDropEdt.setItems(eval(ret)); 8 }); 9 }
疑惑的地方:本地tomcat启动服务没有问题,部署到weblogic上出现错误。