-2

我正在尝试使用 Ext JS 6.2.0 创建一个简单的应用程序 un Netbeans。

在 ui.js 文件中,我只是创建了一个工具栏和一个表单。

var toolbar = Ext.create('Ext.toolbar.Toolbar', {
    renderTo: document.body,
    width   : 400,
    margin  : '5 0 0 0',
    items   : [{
        xtype: 'datefield',
        anchor: '100%',
        format: 'W-Y',
        fieldLabel: 'From',
        name: 'from_date',
        maxValue: new Date()  // limited to the current date or prior
    }]
});

Ext.create('Ext.form.Panel', {
    renderTo: document.body,
    title: 'User Form',
    height: 300,
    width: 585,
    defaults: {
        xtype: 'textfield',
        labelAlign: 'top',
        padding: 10
    },
    layout: 'hbox',
    items: [toolbar]
});

然后在 index.jsp 中,我调用这个文件和其他文件,例如 theme-classic-all-debug.css、theme-classic-debug.js 和 ext-all-debug.js。

我将它与这些标签结合起来:

<script src="WEB-INF/ext-6.2.0/build/ext-all-debug.js" type="text/javascript"></script>

<link href="WEB-INF/ext-6.2.0/build/classic/theme-classic/resources/theme-classic-all-debug.css" rel="stylesheet" type="text/css"/>

但问题是,当我尝试运行应用程序时,在浏览器的控制台中,我看到了这些错误并且页面没有显示任何内容。

错误:

- -西班牙语 - -

El script de “http://localhost:8080/pruebaMCC/WEB-INF/ext-6.2.0/build/ext-all-debug.js” fue cargado a pesar de que su tipo MIME (“text/html”) no es un tipo MIME válido de JavaScript.

Ha fallado la carga del <script> con origen "http://localhost:8080/pruebaMCC/WEB-INF/ext-6.2.0/build/ext-all-debug.js".

- -英语 - -


<script> loading with source "http: // localhost: 8080 / test MCC / WEB-INF / ext-6.2.0 / build / ext-all-debug.js" failed.

我不知道我该如何解决它。

请帮我。

谢谢,苏菲

4

1 回答 1

1

最有可能的问题是没有静态资源。要从jsp模板访问资源,仅指示计算机上资源的路径是不够的。之后,Java 代码将被编译和构建,您的资源将被打包到一个jarorwar中,然后服务器将使用它。最终路径取决于部署 jar 的上下文。

尝试

<script src="<%=request.getContextPath()%>/ext-6.2.0/build/ext-all-debug.js" type="text/javascript"></script>

<link href="<%=request.getContextPath()%>/ext-6.2.0/build/classic/theme-classic/resources/theme-classic-all-debug.css" rel="stylesheet" type="text/css"/>

它可能没有帮助。这完全取决于您在 java 项目中的设置。

于 2020-02-17T15:33:41.830 回答