& lt; Servlet>HelloServlet Com. Example. MyWebsite. HelloServlet
HelloServlet /hello
Behind try many times, found that in fact is the mapping problem, to the point after the mapping can normal visit, excuse me what reason be, will be the servlet write
package com. Example. MyWebsite;
Import the Java. IO. *;
The import javax.mail. Servlet. ServletConfig;
import javax.servlet.ServletException;
The import javax.mail. Servlet. HTTP. *;
The import javax.mail. Servlet. The annotation. *;
@ WebServlet (name="helloServlet" value="https://bbs.csdn.net/hello-servlet")
Public class HelloServlet extends the HttpServlet {
private String message;
Public void init (ServletConfig config) throws ServletException {
}
Public void doGet (it request, HttpServletResponse response) throws IOException, ServletException {
String name=request. The getParameter (" name ");
response.setContentType("text/html; charset=utf-8");
PrintWriter out=response. GetWriter ();
Out.println (" & lt; Html>" +
"& lt; head>The Servlet running & lt;/title> " +
"& lt; body>" +
"& lt;/HTML ");
}
Public void doPost (it request, HttpServletResponse response) throws IOException, ServletException {
DoGet (request, response);
}
Public void destroy () {
}
}
The JSP code:
& lt; % -- --
Created by IntelliJ IDEA.
User: luo xin '
Date: 2021/5/9
Time: :
To change this template use File | Settings | File Templates.
- % & gt;
<% @ page contentType="text/HTML. Charset=utf-8 "language=" Java "% & gt;
Welcome & lt;/title>
<body>Name: & lt; Input the name="name" type="text" & gt;