!!!!dwr怎么上传图片啊?!!!!

逐兔郎 逐兔郎 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
网上找的一个小例子
public String uploadImage(InputStream  Images){

WebContext webContext=WebContextFactory.get();
String saveurl=webContext.getHttpServletRequest().getSession().getServletContext().getRealPath("/image/goods_pic");
File file=new File(saveurl+"/"+"wo");

try {
int available=Images.available();
byte[] b=new byte[available];
FileOutputStream foutput=new FileOutputStream(file);
Images.read(b);
foutput.write(b);
foutput.flush();
foutput.close();
Images.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return "图片上传成功!";
}







java参数是InputStream类型,那么js里面怎么写呢?
var images = dwr.util.getValue('up');
upload.uploadImage(images,msg);
up是<input type="file">的name属性名,msg回调函数,这样子不行,会报错: message[java.lang.IllegalArgumentException: Missing method or missing parameter converters: upload.uploadImage] ,应该是数据类型不匹配吧?那么应该怎么写呢?或者是在dwr.xml里面配置那个converter吗?

我只想用dwr,其他方法不考虑。
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
逐兔郎
Java EE 67,535 成员 225,843 内容