码迷,mamicode.com
首页 > 其他好文 > 详细

Servlet入门

时间:2020-07-01 22:29:13      阅读:57      评论:0      收藏:0      [点我收藏+]

标签:oca   imp   exce   protected   override   tle   ted   BMI   port   

Tomcat初次使用

技术图片

 

//a.html
<!
DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>a</title> </head> <body> <form action="http://localhost:8080/abc/hello" method="get"> <input type="submit"> </form> </body> </html>
//web.xml
<?
xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>com.WebTest01.HelloServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> </web-app>
//index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    This is Faded828x‘s first index.jsp page!
  </body>
</html>
//HelloServlet.java
import
javax.servlet.*; import java.io.IOException; public class HelloServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("doGet"); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("doPost"); } }

 

Servlet入门

标签:oca   imp   exce   protected   override   tle   ted   BMI   port   

原文地址:https://www.cnblogs.com/faded828x/p/13221631.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!