package com.login;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Login extends HttpServlet
{
private static final long serialVersionUID = 2810517636588104181L;
public void doGet(HttpServletRequest req,HttpServletResponse res)
{
//业务逻辑
try
{
PrintWriter pw=res.getWriter();
//中文乱码
res.setContentType("text/html;charset=gb2312");
//返回登入界面
pw.println("<html>");
pw.println("<body>");
pw.println("<h1>登入界面<h1>");
pw.println("<from action=?? method=post>");
pw.println("用户名:<input type=text name=username><br>");
pw.println("密 码:<input type=password name=password><br>");
pw.println("<input type=submit value=login><br>");
pw.println("</body>");
pw.println("</html>");
}catch(Exception e)
{
e.printStackTrace();
}
}
//重写post请求
public void doPost(HttpServletRequest req,HttpServletResponse res)
{
this.doGet(req, res);
}
}
运行结果如下
为什么不支持中文