Java Tomcat 127.0.0.1可以工作,但localhost或externalIP失败
嗨,我有一个带有ajax调用的servlet,比如:Java Tomcat 127.0.0.1可以工作,但localhost或externalIP失败,java,ajax,linux,tomcat,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
$.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/MyApplication
或192.168.0.5:8080/MyApplication
。
我使用更改了/etc/hosts
文件
127.0.0.1localhost
,我在我的/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" />
但问题并没有解决。一些解决方案?如何ping localhost
或ping 192.168.0.5
?这些有用吗?