package com.evalshell.webstudy;
import
org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger;
import
java.io.
*
;
import
javax.servlet.ServletException;
import
javax.servlet.http.
*
;
import
javax.servlet.annotation.
*
;
@WebServlet
(name
=
"helloServlet"
, value
=
"/hello-fengxuan"
)
public
class
HelloServlet extends HttpServlet {
private String message;
private static final Logger logger
=
LogManager.getLogger(HelloServlet.
class
);
public void init() {
message
=
"Hello World!"
;
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType(
"text/html"
);
response.setHeader(
"Content-Type"
,
"text/html; charset=utf-8"
);
System.out.println(request.getQueryString());
/
/
Hello
PrintWriter out
=
response.getWriter();
out.println(
"<html><body>"
);
out.println(
"<span>你好,兄弟,请用post请求来搞我!</span>"
);
out.println(
"</body></html>"
);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String name
=
req.getParameter(
"c"
);
System.out.println(name);
logger.error(name);
resp.setContentType(
"text/html"
);
resp.setHeader(
"Content-Type"
,
"text/html; charset=utf-8"
);
PrintWriter out
=
resp.getWriter();
out.println(
"<html><body>"
);
out.println(
"<h1>可恶!又被你装到了!</h1>"
);
out.println(
"</body></html>"
);
}
public void destroy() {
}
}