这样的问题:The method index0f(String) is undefined for the type String,希望有大师可以解决!!!

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了这样的问题:The method index0f(String) is undefined for the type String,希望有大师可以解决!!!相关的知识,希望对你有一定的参考价值。

下面是我的源代码和报错信息:
<%@ page contentType="text/html; charset=gbk" language="java"
import="java.sql.*,java.util.*,java.text.*,com.jspsmart.upload.*,DBstep.iDBManager2000.*" errorPage="" %>
<%@ include file="../../functions/conn1.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>无标题文档</title>
</head>
<body>
<%
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(Calendar.getInstance().getTime());//新建一个SmartUpload对象
SmartUpload su =new SmartUpload();//上传初始化
su.initialize(pageContext);

su.upload();

for (int i=0;i<su.getFiles().getCount();i++)

com.jspsmart.upload.File file = su.getFiles().getFile(i);
//若文件不存在,则继续
if (file.isMissing()) continue;

String last = file.getFileExt();//提取后缀名并赋值。

file.saveAs("/model/file/" +date+"."+last, su.SAVE_VIRTUAL);

String upPath = "/model/file/"+date+"."+last;
String temp = date+"."+last;
//out.print(upPath);

String name=file.getFileName();
name=name.substring(0,name.index0f(".")); //字符串截取0-19共20位
String time=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
//String path=file.getFilePathName();
sql="insert into forum (f_name,f_patht,f_time) values ('"+name+"','"+upPath+"','"+time+"')";
try

boolean bl=stmt.execute(sql);

catch(SQLException e)
System.out.print("上传异常!");

response.sendRedirect("forum.jsp");

%>
</body>
</html>

报错信息:
An error occurred at line: 63 in the jsp file: /admin/forum/forum_up.jsp
The method index0f(String) is undefined for the type String
60: //out.print(upPath);
61:
62: String name=file.getFileName();
63: name=name.substring(0,name.index0f(".")); //字符串截取0-19共20位
64:
65: String time=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
66: //String path=file.getFilePathName();

参考技术A name=name.substring(0,name.index0f("."));
indexOf,你打的是零本回答被提问者采纳

Java重写父类使用@Override时出现The method destroy() of type xxx must override a superclass method的问题解决

解决方法:

1、把JDK版本改成1.6以上的。

2、把Compiler改成1.6以上的。

关于这两者的区别,参考:http://www.cnblogs.com/EasonJim/p/6741682.html

以上是关于这样的问题:The method index0f(String) is undefined for the type String,希望有大师可以解决!!!的主要内容,如果未能解决你的问题,请参考以下文章

The method xx from the type xx refers to the missing type List等问题的解决办法

关于java 可变参数的问题,The method max(int[]) is ambiguous for the type test

Jquery ajax get request to aspx web method not hit the breakpoint in the method and error is json pa

vuex报错:Property or method “$store“ is not defined on the instance but referenced during render. Make

The method getDispatcherType() is undefined for the type HttpServletRequest 升级到tomcat8(转)

DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connec