1、修改为绝对路径$(document).ready(function(){$.get("${pageContext.request.contextPath}/servlet/Test",null,
function (data) {
alert("hello");
$("#logs").append("[data: " + data + " ]
");
});
});${pageContext.request.contextPath}
相当于得到项目名称,等价于
我的项目名称是weibo_web_tool_ajax 得到的为/weibo_web_tool_ajax
注意:${pageContext.request.contextPath}
是el表达式,只能写在jsp中,不能写在js中
2、直接用 servlet/DataServlet
如果用
/servlet/Test相当于http://localhost:808/servlet/Test