Ext JS + Spring Boot 整合实现文件上传实例

本篇环境及版本

  • Spring Boot 2.5.0
  • Ext JS 7.0.0

前端代码

在Form 里面放置fileuploadfield 类型的字段, 设置name 属性的值, 这个值会作为后端的参数名, 示例代码如下:

[{
        xtype: 'form',
        title: '上传文件',
        width: 400,
        bodyPadding: 10,
        items: [{
            xtype: 'fileuploadfield',
            name: 'myfile',
            fieldLabel: '文件',
            labelWidth: 50,
            allowBlank: false,
            buttonText: '选择文件...'
        }],
        tbar:[{
            text:'上传',
            handler: function () {
                var form = this.up('form').getForm();
                var url = 'http://localhost:8080/extjs/files/upload';
                if (form.isValid()) {
                    form.submit({
                        url: url,
                        waitMsg: 'Uploading your file...',

猜你喜欢

转载自blog.csdn.net/oscar999/article/details/131357973
今日推荐