前端传入后台的图片地址报错
来源:4-13 前后端联调验证整体模块功能
慕数据4226701
2018-12-02
前端上传的图片地址获取不到,alert(shopImg)显示的是[object,file],下面的错是数组越界?大概该从哪里定位问题,之前测试service的时候,图片可以正常存入数据库。是要定位前端的问题吗
Servlet.service() for servlet [spring-dispatcher] in context with path [/o2o] threw exception [Request processing failed; nested exception is java.lang.StringIndexOutOfBoundsException: String index out of range: -1] with root cause
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1927)
at com.im.o2o.util.ImageUtil.getFileExtension(ImageUtil.java:66)
at com.im.o2o.util.ImageUtil.generateThumbnail(ImageUtil.java:38)
at com.im.o2o.service.ShopServiceImpl.addShopImg(ShopServiceImpl.java:46)
at com.im.o2o.service.ShopServiceImpl.addShop(ShopServiceImpl.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
2回答
-
翔仔
2018-12-02
此类问题比较明确,请同学一定要培养自己通过调试独立解决问题的能力,因为错误信息也报得比较明确
052018-12-04 -
翔仔
2018-12-02
如果是这种情况,就需要同学你定位com.im.o2o.util.ImageUtil.getFileExtension(ImageUtil.java:66),设置断点在这行代码上,看看当时的getFileExtension这个方法为什么会出错
012018-12-03
相似问题