servlet文件中包含有中文,使用javac进行编译时,要加上-encoding 指定编码格式,才可以编译通过问题的情况如下: 1 import java.io.IOException; 2 3 import javax.servlet.ServletException; 4 ...
servlet文件中包含有中文,使用javac进行编译时,要加上-encoding 指定编码格式,才可以编译通过
问题的情况如下:
1 import java.io.IOException; 2 3 import javax.servlet.ServletException; 4 import javax.servlet.http.HttpServlet; 5 import javax.servlet.http.HttpServletRequest; 6 import javax.servlet.http.HttpServletResponse; 7 8 public class LoginServlet extends HttpServlet { 9 @Override10 protected void doGet(HttpServletRequest req, HttpServletResponse resp)11 throws ServletException, IOException {12 resp.setContentType("text/html;charset=UTF-8");13 14 String name=req.getParameter("username");15 String pwd=req.getParameter("password");16 17 if(name!=null&&pwd!=null&&name.equals("dai")&&pwd.equals("123")){18 resp.sendRedirect("success.html");19 }else{
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:servlet中文乱码问题之resp.sendError
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。