Tomcat 127.0.0.1有效,但localhost或externalIP失败

时间:2014-12-06 15:35:27

标签: java ajax linux tomcat

我有一个带有ajax调用的servlet,如:

$.ajax({
        url: "http://127.0.0.1:8080/MyApplication/MyServlet",
        data: {user:name, surname:surname},
        type:"GET",
        crossDomain: true,
         contentType: 'text/plain',
        success: function(data,stato){
            alert("dati: " + data + "\n stato: " + stato);
            $("#pannello").empty().append(data);
        },
        error: function(richiesta, stato, errori){
            alert("errore:" + stato);

        },

    });

当我尝试使用它时,使用127.0.0.1:8080/MyApplication效果很好,但不起作用localhost:8080/MyApplication192.168.0.5:8080/MyApplication。 我使用更改了/etc/hosts文件  127.0.0.1 localhost我添加了/var/lib/tomcat7/conf/server.xml

    <Connector port="8080" protocol="HTTP/1.1"
address="0.0.0.0"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               redirectPort="8443" />

但问题并未解决。一些解决方案?

0 个答案:

没有答案