helloweb

今天演示第一个web小程序

首先列举所需工具

1.tomcat9.0.13服务器软件

2.eclipse软件

 

首先使用eclipse切换到javaweb工作空间

点击这个按钮在里面找到javaEE就OK了

接下来创建一个动态javaweb项目

写一下如下代码

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class helllo
 */
@WebServlet("/helllo")
public class helllo extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public helllo() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Hello World!!!").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}

  然后就ojbk了

posted @ 2018-11-27 23:43  没有昵称的小菜鸟  阅读(352)  评论(0编辑  收藏  举报