再找个位置配置你下载的Tomcat的版本
点击next
Tomcat存放的位置
本地JRE
点击finish结束
新建完成
三、实现一个表单提交验证
1.在Java Resources下的src下通过new创建一个包,并在该包下创建一个servlet类
点击next
(输入描述后点击next)
(初学的话,不需要更改)
-
-
- 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 TextServlet
- */
- @WebServlet(description = "chapter01 Servlet", urlPatterns = { "/TextServlet" })
- public class TextServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
-
- /**
- * @see HttpServlet#HttpServlet()
- */
- public TextServlet() {
- 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("Served at: ").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);
- }
-
- }
(自动生成的代码)
2.在WebContent下创建jsp文件,命名denglu.jsp
测试一下