亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

ajax訪問servlet沒反應

ajax訪問servlet沒反應

我愛靜靜0 2016-07-09 19:16:30
?<script type="text/javascript" src="WEB-INF/lib/jquery-1.8.3.js"></script>? <script type="text/javascript">? function bb(){????? $.get("aja");???????????????? ????? ?? }? </script>? </head>? <a href="javascript:bb()">aa</a>? <a href="aj">bb</a>? <body>?? ?? </body>servlet中:package servlet;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;@WebServlet (urlPatterns={"/aja"})public class aj extends HttpServlet {?? ?/**?? ? * The doGet method of the servlet. <br>?? ? *?? ? * This method is called when a form has its tag value method equals to get.?? ? * ?? ? * @param request the request send by the client to the server?? ? * @param response the response send by the server to the client?? ? * @throws ServletException if an error occurred?? ? * @throws IOException if an error occurred?? ? */?? ?public void doGet(HttpServletRequest request, HttpServletResponse response)?? ??? ??? ?throws ServletException, IOException {?? ??? ?response.setContentType("text/html");?? ??? ?PrintWriter out = response.getWriter();?? ??? ?out.print("false");?? ??? ?out.flush();?? ??? ?out.close();?? ?}?? ?/**?? ? * The doPost method of the servlet. <br>?? ? *?? ? * This method is called when a form has its tag value method equals to post.?? ? * ?? ? * @param request the request send by the client to the server?? ? * @param response the response send by the server to the client?? ? * @throws ServletException if an error occurred?? ? * @throws IOException if an error occurred?? ? */?? ?public void doPost(HttpServletRequest request, HttpServletResponse response)?? ??? ??? ?throws ServletException, IOException {?? ??? ?doGet(request, response);?? ?}}
查看完整描述

2 回答

已采納
?
HansonQ

TA貢獻223條經驗 獲得超56個贊

a標簽 寫到body 標簽里面

查看完整回答
1 反對 回復 2016-07-09
?
我愛靜靜0

TA貢獻1條經驗 獲得超0個贊

放在里面了還是不行啊

查看完整回答
反對 回復 2016-07-10
  • HansonQ
    HansonQ
    $.get("aja");這個地方有問題 . 在js里面 先 var basePath = <%=request.getContextPath()%> ; 然后var rquestPath=basePath+"/"+"aja" 然后換成:$.get(rquestPath);
  • HansonQ
    HansonQ
    $.ajax({ type: "GET", url: "test.js", dataType: "script" }); 在看看是不是你的ajax 寫的有問題
  • 2 回答
  • 0 關注
  • 2803 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號