1.ajax写法
1 $(function(){ 2 $("#openDB").click(function(){ 3 /*$.post("/DBLanguage/LanguageServlet",{"username":"123","password":"456"},function (data) { 4 alert(data); 5 });*/ 6 7 $.ajax({ 8 type:"post", 9 url:'${pageContext.request.contextPath}/LanguageServlet', 10 data:"username=123&password=456", 11 dataType:"text", 12 success:function(data){ 13 alert(data); 14 } 15 }); 16 }); 17 });
2.jsp页面获取当前路径:${pageContext.request.contextPath}