如何使用vaadin上传图像

时间:2013-05-17 06:26:53

标签: java vaadin

我有一种以下的html

<html>
    <head>
        <title>Upload a file please</title>
    </head>
    <body>
        <h1>Please upload a file</h1>
        <form method="post" action="http://localhost:8080/service/uploadFile" enctype="multipart/form-data">
            <input type="text" name="name"/>
            <input type="file" name="file"/>
            <input type="submit"/>
            <input type="hidden" name="smallSize" value="50x50">
            <input type="hidden" name="mediumSize" value="100x100">
            <input type="hidden" name="largeSize" value="150x150">
        </form>
    </body>
</html>

我想使用Vaadin Upload component来做这件事?我怎样才能做到这一点?

3 个答案:

答案 0 :(得分:0)

你不能将普通的html页面与vaadin混合处理“结果”。

他们要去的方法是在你的html页面中嵌入vaadin。

看这里:

https://vaadin.com/de/book/vaadin7/-/page/advanced.embedding.html

答案 1 :(得分:0)

我使用https://vaadin.com/directory#addon/easyuploads。 例如:

final UploadField uploadField = new UploadField();
Button b = new Button("Show value");
b.addListener(new Button.ClickListener() {        
    public void buttonClick(ClickEvent event) {
        Object value = uploadField.getValue();
        mainWindow.showNotification("Value:" + value);
    }
});

答案 2 :(得分:0)

您可以使用vaadin-upload上传一张具有属性(maxfiles)的图片

相关问题