大家好我正在使用javascript来填充值。我正在使用这个脚本
String Vegs[]= request.getParameterValues("Vegs");
String qty_carrot=request.getParameter("quantity_carrot");
String qty_tomato=request.getParameter("quantity_tomato");
String qty_cabbage=request.getParameter("quantity_cabbage");
String qty[];
qty[0]=qty_carrot;
qty[1]=qty_tomato;
qty[2]=qty_cabbage;
但它说错误局部变量qty尚未初始化..
当我将代码更改为此
时String qty[]=new array(3);
qty[0]=qty_carrot;
qty[1]=qty_tomato;
qty[2]=qty_cabbage;
它说数组无法解析为类型
堆栈追踪:@aravind
堆栈跟踪:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:446)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:405)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
答案 0 :(得分:0)
您必须创建如下数组:
String qty[] = new String[3];//<-- 3 is the size of array, you may change it