The project structure is as follows:
HelloServlet. Java
package com. Zixue. Servlet.
import java.io.IOException;
The import javax.mail. Servlet. Servlet.
The import javax.mail. Servlet. ServletConfig;
import javax.servlet.ServletException;
The import javax.mail. Servlet. ServletRequest;
The import javax.mail. Servlet. ServletResponse;
/* *
* @ the ClassName: HelloServletDemo1
* @ Description: introduction to the servlet program
* @ author: sadfoo2019
* @ date: March 2, 2020 morning 1:54:10
* @ Copyright:
*/
Public class HelloServlet implements the Servlet {
@ Override
Public void destroy () {
}
@ Override
Public ServletConfig getServletConfig () {
return null;
}
@ Override
Public String getServletInfo () {
return null;
}
@ Override
Public void init (ServletConfig arg0) throws ServletException {
}
/* *
* used to handle the customer's request and response to the request of method
*/
@ Override
Public void service (ServletRequest request, ServletResponse response) throws ServletException, IOException {
//to the page output a hellServlet string
The response. GetWriter (). Print (" Hello Servlet... ");
}
}
Web.xml
<? The XML version="1.0" encoding="utf-8"?>XMLNS="http://java.sun.com/xml/ns/javaee"
Xsi: schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
Id="WebApp_ID" version="2.5" & gt;Test_TomcatServers & lt;/display - name> Index. Html Index. Htm Index. Jsp Default. Html Default. Htm Default. Jsp HelloServlet Com. Zixue. Servlet. HelloServlet
HelloServlet /aaa
CodePudding user response:
Copy your code, no problem, can run, you can copy code into another bag to try,CodePudding user response:
The