继承HTTPSERVLET类,重写doGet()、doPost()方法,;在web.xml中配置两个标签:<servlet>,<servlet-mapping>;
web.jsp
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>servlet.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/servlet/HelloServlet</url-pattern>
</servlet-mapping>
index.jsp
<a href="servlet/HelloServlet">Get方式请求HelloServlet</a>
<form action="servlet/HelloServlet" method="post">
<input type="submit" value="Post方式请求HelloServlet!">
</form>
2.查看端口
终端输入:lsof -i tcp:port 将port换成被占用的端口(如:8086、9998)
将会出现占用端口的进程信息。
3.kill进程
找到进程的PID,使用kill命令:kill PID(进程的PID,如2044),杀死对应的进程