forked from jasder/java_ci
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
932 B
36 lines
932 B
package controller;
|
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.annotation.WebServlet;
|
|
import javax.servlet.http.HttpServlet;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.PrintWriter;
|
|
|
|
public class HelloWorld extends HttpServlet {
|
|
|
|
private String message;
|
|
|
|
@Override
|
|
public void init() throws ServletException {
|
|
message = "Hello world, this message is from servlet! 2022-10-17 20:20";
|
|
}
|
|
|
|
@Override
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
//设置响应内容类型
|
|
resp.setContentType("text/html");
|
|
|
|
//设置逻辑实现
|
|
PrintWriter out = resp.getWriter();
|
|
out.println("<h1>" + message + "</h1>");
|
|
}
|
|
|
|
@Override
|
|
public void destroy() {
|
|
super.destroy();
|
|
}
|
|
|
|
}
|