使用ajax从html调用servlet时出现404错误

时间:2013-04-02 11:03:02

标签: java jquery

我已经创建了servlet以获取数据,我使用ajax函数从HTML文件调用该servlet并得到如下所示的错误:

http://localhost:8080/ArachneResult?operationConnectorFName=CONTAINS&
 operationConnectorLName=CONTAINS&operationConnectFName=CONTAINS&
 operationConnectLName=CONTAINS&operationConnectTitle=CONTAINS&
 operationEntity=CONTAINS&searchConnectorFName=&searchConnectorLName=kagermann&
 searchConnectFName=&searchConnectLName=&searchConnectTitle=&
 searchEntity=Failed to load resource: the server responded with a status of 404 (Not Found)

这是我在web.xml中映射到servlet的javascript代码:

  var URL = '/serveltName';
$.ajax({ 
    type: 'GET', 
    url: URL, 
    data: jsondata, 
    dataType: 'json',
    success: function (data) { 
        console.log(data);
        var length = data.length;
        $('#length').innerHTML(length);
        $.each(data, function(index, data) {
            $('body').append($('<li style="background-color: #E0FFFF;"><table><tr><td width="52" style="max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">'+data.ConnectorFName+'</td><td width="60">'+data.connectorLName+'</td><td width="135">'+data.connectorEmail+'</td><td width="55">'+data.connectFName+'</td><td width="58">'+data.connectLname+'</td><td width="100">'+data.entity+'</td><td width="120">'+data.title+'</td><td width="60">'+data.comment+'</td></tr></table></li>', {
            }));
        });
    },
    error: function(jqXHR, textStatus, errorThrown) {
          console.log(textStatus, errorThrown);
        }
});

0 个答案:

没有答案