关于JSP的问题!打开文件对话框的问题,请教高手!

strongsoft 2003-04-09 11:19:39
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.awt.FileDialog"%>
<html>
<head>
<title>
zq
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
<%
//FileDialog opendg = new FileDialog(this,"LOAD",FileDialog.LOAD);
FileDialog fileDialog=new java.awt.FileDialog(this);
fileDialog.setMode(FileDialog.LOAD);
fileDialog.setTitle("Choose the browser to use:");
fileDialog.setVisible(true);
fileDialog.show();
%>
</h1>
</body>
</html>

请问在JSP代码中可这么写吗为什么我运就是出错呢没有对话框呢?
请教各位老师请多多帮忙!
...全文
111 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
zqhero123 2003-04-10
  • 打赏
  • 举报
回复
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.awt.FileDialog"%>
<html>
<head>
<title>
zq
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
<%
//FileDialog opendg = new FileDialog(this,"LOAD",FileDialog.LOAD);
FileDialog fileDialog=new java.awt.FileDialog(this);
fileDialog.setMode(FileDialog.LOAD);
fileDialog.setTitle("Choose the browser to use:");
fileDialog.setVisible(true);
fileDialog.show();
%>
</h1>
</body>
</html>
strongsoft 2003-04-09
  • 打赏
  • 举报
回复
wellsoon(wellsoon)我知道用表单的这种方法!
但是有个问题就是文件的类型,只要的.JPG的我怎么做呢?
strongsoft 2003-04-09
  • 打赏
  • 举报
回复
不对呀上面的程序我照shkwh(龙威)那么写的,错误是没有了,但是对话框是没有弹出来呀!
wellsoon 2003-04-09
  • 打赏
  • 举报
回复
html代码:

<input type=file name="file1">

hocus 2003-04-09
  • 打赏
  • 举报
回复
问题是,的确是出来了
strongsoft 2003-04-09
  • 打赏
  • 举报
回复
我在想问一下,一些网站的文件浏览对话框是怎么实现的呢?
我想做一个文件选择上传的,请多多指教!

那我的客户端用javascript 来实现文件浏览对话框吗?
那用JSP怎么做呢?
shkwh 2003-04-09
  • 打赏
  • 举报
回复
我试了一下,是可以的。
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.awt.*"%>
<html>
<head>
<title>
test2
</title>
</head>
<body>
<%
Frame f=new Frame("文件操作窗口");
FileDialog fileDialog=new java.awt.FileDialog(f);
fileDialog.setMode(FileDialog.LOAD);
fileDialog.setTitle("Choose the browser to use:");
fileDialog.setSize(400,300);
fileDialog.setVisible(true);
%>

</body>
</html>
secrets001 2003-04-09
  • 打赏
  • 举报
回复
不行,真的不行,客户端是浏览器,你的jsp到达客户端是已经被解释成html了,你的这段程序再html里是没有意义的。
flashroom 2003-04-09
  • 打赏
  • 举报
回复
不是吧,这样都可以????

-------------------------------------------------------------------
我的签名:我做了两天斑竹就被撤了,为什么????
dybine 2003-04-09
  • 打赏
  • 举报
回复
这个可以吗?好像没听说过啊,应该是不行的,那岂不是B/S的东西都做成C/S的了
strongsoft 2003-04-09
  • 打赏
  • 举报
回复
我们公司不准用控件类的,只能是纯JSP的!
conning333 2003-04-09
  • 打赏
  • 举报
回复
用javascript判断文件类型。eg:
if(filestr.indexOf(".jpg")<0)return false;
bjzhanghao 2003-04-09
  • 打赏
  • 举报
回复
看smartupload的文档和例子
wellsoon 2003-04-09
  • 打赏
  • 举报
回复
试一下:
<input name="picture" type=file name=file1 accept="image/jpeg">

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧