这样的问题:The method index0f(String) is undefined for the type String,希望有大师可以解决!!!
下面是我的源代码和报错信息:<%@pagecontentType="text/html;charset=gbk"language="java"import="java.s...
下面是我的源代码和报错信息:
<%@ 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(); 展开
<%@ 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(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询