단순텍스트
HTML
HTTP API - Json 등
@WebServlet(name="responseHtmlServlet", urlPatterns = "/response-html")
public class ResponseHtmlServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.println("<html>");
writer.println("<head>");
writer.println("</head>");
writer.println("<body>");
writer.println("<div>");
writer.println("안녕");
writer.println("</div>");
writer.println("</body>");
writer.println("</html>");
}
}
먼저 콘텐츠 타입, 인코딩 설정해주고
writer 얻어와서 거기에 html 직접 씀.
'스프링 > 3. 스프링 MVC' 카테고리의 다른 글
17. 회원관리 웹 애플리케이션 개요 (0) | 2023.08.05 |
---|---|
16. HTTP 응답 HTTP API - JSON (0) | 2023.08.05 |
14. HttpServletResponse (0) | 2023.08.05 |
13. HTTP API JSON (0) | 2023.08.04 |
12. HTTP API 요청 데이터 (0) | 2023.08.04 |