2023-09-03
package com.hh.response; /** * @author hh * @version 1.0 * @DATE 2023-09-03 13:32:10 */ 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; @WebServlet("/resp3") public class ResponseServlet3 extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //字符流 response.setCharacterEncoding("utf-8"); response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.write("花花最棒"); writer.write("<h1>花花最棒</h1>"); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
标签:字符,ServletException,HttpServletResponse,response,案例,import,servlet,javax From: https://www.cnblogs.com/isDaHua/p/17674922.html