请大侠们帮忙!最好代码贴全一点,从读到到下载下来。谢谢各位了!
我要读的服务器上面得都是.vox文件。
我要读的服务器上面得都是.vox文件。
解决方案 »
- 报错:HTTP Status 405 - HTTP method GET is not supported by this URL
- org.apache.jasper.JasperException: /pages/teacherlist.jsp(130,0) Unterminated &l
- 郁闷啊~~~到底是哪里错了,各位兄弟帮忙看看~~
- 有熟悉GWT的吗,如何通过GWT的按钮的点击事件,是当前页面转换到另外一个页面
- 站点间如何通讯?
- 谁给介绍一下现在流行的Web开发方案和趋势,另求关于框架方面的好的电子书
- JCREATER3.1中不能显示中文
- 300分求教:我用JSP开发的一个WEB应用,网页传输不完整,每次都不全。回答正确另开贴子给分。
- 字符串之间的比较的问题?
- 为什么我的"import Javax.Servlet.http.*;"not exist?????
- java小题
- 请教关于applet
先用个bean封装你的FILE信息!
File file = new File("");
File[] files = file.listFiles();
for(int i=0;i<files.length;i++){
//封装你的实体bean
///list.add(bean);
}
用list返回页面。
第二步就从页面传文件的绝对路径回Action;
OutputStream os = this.getResponse().getOutputStream();
this.getResponse().setHeader("Content-Disposition", "attachment; filename=你想要的文件");
FileInputStream in = new FileInpustStram("页面获取的路径");
byte[] b = new byte[1024];
while((int len = in.read(b,0,b.length))!=-1){
os.write(b,0,b.length);
os.flush();
}
in.close();
貌似简单代码就是这样!希望能帮到你!
我照着你的代码写一段
//播放录音
public ActionForward record(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("record");
Map paramMap = this.getParamMap(form); User u = super.getCurUser();
String username = u.getUsername();
String url = "\\"+File.separator+"192.168.0.6"+File.separator+"record";
List list = new ArrayList();
File f = new File(url);
String[] names = f.list();
//如果是管理员,能听到所有的录音
if(username.trim()=="admin"||username.trim().equals("admin"))
{
for(int i=0;i<names.length;i++)
{
String recordurl = url+File.separator+names[i];
String recordurlall = recordurl;
String name = names[i];
Map map = new HashMap();
map.put("recordurlall", recordurlall);
map.put("name", name);
list.add(map);
}
request.setAttribute("list", list);
return mapping.findForward("recordAll");
}
else
{
for(int i=0;i<names.length;i++)
{
if(username.trim()==names[i].trim()||username.trim().equals(names[i].trim()))
{
String recordurl = url+File.separator+names[i];
list = getUrl(recordurl);
}
}
request.setAttribute("list", list);
}
return mapping.findForward("record");
}
1,是可以用了,但是在用之前必须要先在电脑的运行里面运行一下\\192.168.0.6\record,然后再输一下用户名和密码进去之后,我的程序才可以使用,否则会抱空指针错(没有取道路径下面的所有名字)。
2,按照上述的我现在电脑运行里面运行了\\192.168.0.6\record,我在MyEclipse中可以,但是放在了Tomcat单独访问就报空指针了。
请各位大侠帮帮忙,有没有解决的办法。谢谢各位了