0

For starters I'm brand new to ExtJS

Thanks for taking a moment to look at my problem, so far I haven't been able to find any equivalent questions anywhere. I'm attempting to transition a webapp interface from Tiles/Spring/jQuery to a Tiles/Spring/ExtJS interface, but I'm having trouble in getting some of the basics started.

For starters, the code:

Ext.onReady(function() {

    Ext.QuickTips.init();

    var login = new Ext.FormPanel({
        title: "Please Login",
        url: 'j_spring_security_check',
        labelWidth: 80,
        frame: true,
        defaultType: 'textField',
        width: 300,
        height: 150,
        monitorValid: true,
        bodyStyle: 'padding:10px',
        items: [{
            fieldLabel: 'Username',
            name: 'j_username',
            id: 'userName',
            allowBlank: false,
            listeners: {
                afterrender: function(field) {
                    field.focus();
                }
            }
        }, {
            fieldLabel: 'Password',
            name: 'j_password',
            inputType: 'password',
            allowBlank: false
        }],
        buttons: [{
            text: 'Login',
            formBind: true,
            handler: function() {
                loginSubmit();
            }
        }, {
            text: 'Reset',
            formBind: true,
            handler: function() {
                reset();
            }
        }],
        listeners: {
            afterRender: function(thisForm, options) {
                this.keyNav = Ext.create('Ext.util.KeyNav', this.el, {
                    enter: loginSubmit,
                    scope: this
                });
            }
        }
    });

    function reset() {
        login.getForm().reset();
    }

    function loginSubmit() {
        login.getForm().submit({
            method: 'POST',
            success: function(form, action) {
                window.location = 'home';
            },
            failure: function(form, action) {
                Ext.Msg.alert('Login Failed!', 'Login Failed');
                reset();
            }
        });
    }

    login.render('login');
});

And this is wrapped properly in the script tags, in a jsp page.

I import the extJS files in the tile page that this JSP renders to:

<link type="text/css" rel="stylesheet" href="extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/ext-all-debug.js"></script>

And at this point I'd expect things to render somehow, but instead I get this: firebug error

Strangely, the files do load successfully (at least they don't appear with an error) except that it shows a responseBody of 0 bytes, as you can see in lines 2 and 3 below. firebug response

I've looked around and already tried all the easy fixes to the best of my ability, I'm hoping someone here will be able to help. Thanks again for taking the time to look at my problem.

Update

When I changed out the script reference to the sencha CDN, I get past this error on to a new one, but I want to stick with this and resolve this first.

My best guess now based on the comments below is that I'm either missing ext-base.js (which is not included in the ExtJS I have downloaded) or I somehow have my file location/Spring config wrong. I've added these entries to my spring config now:

<mvc:resources location="/WEB-INF/extjs/*" mapping="/extjs/**" />
 ....
    <security:intercept-url pattern="/appName/extjs/**"
  access="permitAll" requires-channel="any" />

And yet I still have the same error. I've got the extjs folder in my WEB-INF directory, shouldn't that mvc:resources above fix that so I can reference it like so:

< script type="text/javascript" src="extjs/ext-all-debug.js"

Yet I still get the "302 found" error

4

2 回答 2

1

正如您在网络流量历史记录(您的最新图像)中看到的,未找到 extjs 文件(ext-all-debug.js 和 ext-all.css)。更有趣的是,错误代码是 302(可能是重定向),而不是更常见的 404。

无论如何,这就是你得到 0 字节响应的原因,因为资源不存在。您可以查看失败请求的详细信息以查看更多详细信息,但基本上您应该验证文件位置和服务器/应用程序配置,以查看为什么找不到这些文件。

更新:

大多数情况下,此类问题是因为您未通过身份验证。然后,当您执行 GET 请求时,服务器会检查您未通过身份验证,然后将您(302 错误代码)重定向到登录页面。

使用 CDN 是可行的,因为您不必在 CDN 服务器上进行身份验证!

即使您未通过身份验证,登录页面也必须有权访问它需要的所有资源。

可悲的是,我不知道您正在使用的技术,但这就是您正在遭受的问题。

于 2012-12-18T23:28:15.687 回答
0

你不是想念这个吗……?

<script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>

路径可能错误,您可能需要更正

更新

不需要 ext-base.js,而且确实在任何地方都找不到它。检查您的代码以查看是否包含所有这些

我将只发布我的 index.php 的头部

<head>

    <META http-equiv="Content-Type" content="text/html; charset=utf-8">

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">

    <META HTTP-EQUIV="Expires" CONTENT="-1">

    <title>Page Title</title>

    <link rel="stylesheet" type="text/css" href="lib/ext/resources/css/ext-all.css"/>
    <link rel="stylesheet" type="text/css" href="src/views/css/data-view.css" />

    <script type="text/javascript" src="lib/ext/ext-all-debug.js"></script>
    <script type="text/javascript" src="src/app.js"></script>
</head>
于 2012-12-18T23:33:05.303 回答