猿问

ajax访问servlet没反应

 <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);
    }

}


我爱静静0
浏览 2742回答 2
2回答

HansonQ

a标签 写到body 标签里面

我爱静静0

放在里面了还是不行啊
随时随地看视频慕课网APP

相关分类

Java
JQuery
我要回答