首页 > 学院 > 开发设计 > 正文

Serlet输出中文、感叹号乱码等的解决办法

2019-11-08 03:11:21
字体:
来源:转载
供稿:网友
import java.io.IOException;import javax.servlet.Servlet;import javax.servlet.ServletConfig;import javax.servlet.ServletException;import java.io.PRintWriter;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;public class PrintToBrowser implements Servlet {public void destroy(){}public ServletConfig getServletConfig(){return null;}public  String getServletInfo(){return null;}public  void init(ServletConfig config)throws ServletException{}public void service(ServletRequest req, ServletResponse res)throws IOException, ServletException{req.setCharacterEncoding("utf-8");   res.setContentType("text/html;charset=utf-8");   res.setCharacterEncoding("utf-8");          PrintWriter out=  res.getWriter();out.print("<html>");out.print("<body>");         out.print("<h1 align='center'><font color='red'> Welcome Page!!!谢谢</font></h1>"); out.print("</body>");out.print("</html>"); }

}


上一篇:c#实现的LRU算法

下一篇:IP分片

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表