service方法如下:
protected voidservice(HttpServletRequest request, HttpServletResponseresponse)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out =response.getWriter();
out.println("hello");
out.close();
//forward("/jsp/ajaxtest.jsp",request, response);
}
forward方法:
public void forward(String url,HttpServletRequest request,
HttpServletResponseresponse) throws ServletException,IOException
{
ServletContext sc =getServletConfig().getServletContext();
RequestDispatcher rd =sc.getRequestDispatcher(url);
rd.forward(request,response);
}
说明:
如果想跳转到其他页面就写forward方法,如果想跳转到发出请求的页面就不用写forward方法,out.println("hello");的值直接可以传到请求页面上。
补续:
页面的<tableborder="1"></table>
out.println("<table border='1'></table>");
因为out.println("");只认一对双引号。