简体   繁体   中英

Call java class from ExtJs ajax call

Using Extjs + Maven + Spring.

I am writing an Extjs code. I want to update my jason file. Therefore I have to use any server side programming. I want to use JAVA for that.

Ext.Ajax.request({
    url: 'HelloWorld',
    method: 'POST',
    params: {
        id: openwindows,
        state: space
    },                                                                              
    scope : this,
    success: function(response){
        var text = response.responseText;
        // process server response here
        //alert(text);
        console.log(text);
    },
    failure: function ( response ) {
        var text = response.responseText;
        //alert(text);
        console.log(text);
    }
});

But it gets me an error

HTTP ERROR 404

Problem accessing /parent/HelloWorld. Reason:

 NOT_FOUND  


Powered by Jetty://

I tried 100 things to get this work but I had no luck.

Do I have to follow such structure for the JAVA/Servlet side.

If anyone knew that please let me know.

Kind Regards, Justin

I think you are trying to make ajax call to spring services.Do something below.Pass the full URL of your backend service.Make sure that you are passing correct URL,header information and post parameters.

Ext.Ajax.request({
    url: 'http://ip_address:port/HelloWorld',
    method: 'POST',
    params: {
        id: openwindows,
        state: space
    },                                                                              
    scope : this,
    success: function(response){
        var text = response.responseText;
        // process server response here
        //alert(text);
        console.log(text);
    },
    failure: function ( response ) {
        var text = response.responseText;
        //alert(text);
        console.log(text);
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM