我有一个带有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/MyApplication
或192.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" />
但问题并未解决。一些解决方案?