然后是请求的资源,teaServlet的代码
package admin;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class teaServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public teaServlet() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
out.println("<response>");
out.println("<message>");
out.println("<teaName>Jonny</teaName>");
out.println("<teaPass>34</teaPass>");
out.println("<teaRealName>sdf</teaRealName>");
out.println("<teaDiscription>afsd</teaDiscription>");
out.println("</message>");
out.println("<message>");
out.println("<teaName>Jonnasdfy</teaName>");
out.println("<teaPass>3dsaf4</teaPass>");
out.println("<teaRealName>sdasfdf</teaRealName>");
out.println("<teaDiscription>aasdffsd</teaDiscription>");
out.println("</message>");
out.println("</response>");
System.out.println("成功");
out.flush();
out.close();
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
public void init() throws ServletException {
// Put your code here
}
}