求一个方法!在线等,谢谢! 把request或者文件fileName传给bean,接下来该怎么搞就怎么搞阿,呵呵但是有这个必要吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class TmpgetName{private String tmpName=""; public TmpgetName(String fileName){ tmpName=fileName.substring(fileName.lastIndexOf("/")+1,fileName.length()); }public String getFileName(){ retrun tmpName;}} 我想 是老板让你作成 javabean 吧!那就在前面加上 <jsp:useBean id="niyaode Id" scope="session" class="firstbean"/> //请放置一个 文本文件到 afile.txt 到 web 目录下的 test目录 javabean 将文件放到对应的 class 目录下!(tomcat)<html><head><title>读取一个文件</title></head><body bgcolor="#000000"><%-- 调用 javaBean --%><jsp:useBean id="reader" class="DelimitedDateFile" scope="request"><jsp:setProperty name="reader" property="path" value="/edu.war/afile.txt"/></jsp:useBean></h3>文件内容</h3><p><% } %></p></body><html>//DelimitedDataFile.java bean 源文件//导入 java 包import java.io.*;import java.util.StringTokenizer;public class DelimitedDataFile{ private String currentRecord = null; private BufferedReader file; private String path; private StringTokenizer token; //创建文件对象 public DelimitedDataFile() { file = new BufferedReader(new InputStreamReader(System.in),1); } public DelimitedDataFile(String filePath) throws FileNotFoundException { path = filePath; file = new BufferedReader(new FileReader(path)); } public void setPath(String filePath) { path = filePath; try { file = new BufferedReader(new FileReader(path)); } catch(FileNotFoundException e) { System.out.println("file not found"); } } //得到文件路径 public String getPath() { return path; } public void fileClose() throws IOException { file.close(); } //读取下一行记录, 若没有则返回 -1 public int nextRecord() { int returnInt = -1; try { currentRecord = file.readLine(); } catch (IOException e) { System.out.println("readLine Problem, terminating."); } if(currentRecord == null) returnInt = -1; else { token = new StringTokenizer(currentRecord); returnInt = token.countTokens(); } return returnInt; } //以字符串的形式返回记录 public String returnRecord() { return currentRecord; }} 问个很菜的问题!大家不许笑 保存数据问题 div滚动条位置的问题 struts奇怪的问题 关于记录集问题!请高手指点 问HIBERNATE一句查询语句 为什么rs.next后就出错???? struts2-core-2.0.11.1.jar引用dojo不支持IE10,求解决办法 这样的模式该如何实现呢? 用js来判断是什么操作,把这个参数传给servlet,让它真正来转发 重定向(sendRedirect)跳不出框架怎么解决? [求助] Servlet中的中文显示问题! 关于sql server JDBC 一问
{
private String tmpName="";
public TmpgetName(String fileName)
{
tmpName=fileName.substring(fileName.lastIndexOf("/")+1,fileName.length());
}public String getFileName()
{
retrun tmpName;}}
<jsp:useBean id="niyaode Id" scope="session" class="firstbean"/>
<head>
<title>读取一个文件</title>
</head>
<body bgcolor="#000000">
<%-- 调用 javaBean --%>
<jsp:useBean id="reader" class="DelimitedDateFile" scope="request">
<jsp:setProperty name="reader" property="path" value="/edu.war/afile.txt"/>
</jsp:useBean>
</h3>文件内容</h3>
<p>
<% } %>
</p>
</body>
<html>
//DelimitedDataFile.java bean 源文件
//导入 java 包import java.io.*;
import java.util.StringTokenizer;
public class DelimitedDataFile
{
private String currentRecord = null;
private BufferedReader file;
private String path;
private StringTokenizer token; //创建文件对象
public DelimitedDataFile()
{
file = new BufferedReader(new InputStreamReader(System.in),1);
}
public DelimitedDataFile(String filePath) throws FileNotFoundException
{
path = filePath;
file = new BufferedReader(new FileReader(path));
}
public void setPath(String filePath)
{
path = filePath;
try
{
file = new BufferedReader(new FileReader(path));
}
catch(FileNotFoundException e)
{
System.out.println("file not found");
}
} //得到文件路径
public String getPath()
{
return path;
} public void fileClose() throws IOException
{
file.close();
} //读取下一行记录, 若没有则返回 -1
public int nextRecord()
{
int returnInt = -1;
try
{
currentRecord = file.readLine();
}
catch (IOException e)
{
System.out.println("readLine Problem, terminating."); }
if(currentRecord == null)
returnInt = -1;
else
{
token = new StringTokenizer(currentRecord);
returnInt = token.countTokens();
}
return returnInt;
}
//以字符串的形式返回记录
public String returnRecord()
{
return currentRecord;
}
}