curl的封装

首先要搭建一个http服务器,这里采用tomcat6为例:

过程:新建一个Servlet,并使用tomcat的默认端口号8080监听,最后写一个jsp来测试是否可以访问该服务器

1)新建一个Serlvet

新建完后加入写下测试代码:

public class TestServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public TestServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("test", "test");
		request.getRequestDispatcher("index.jsp").forward(request, response);

	}

}
该Servlet的名字是TestServlet,所以把web.xml中的内容改成以下内容



  TestServlet

  
    TestServlet
    com.test.servlet.TestServlet
  
  
    TestServlet
    /TestServlet
  &

你可能感兴趣的:(C++,cocos2d-x,cocos2d-x,curl)