@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); PrintWriter pw = resp.getWriter(); if("name=Bob".equals(req.getQueryString())) { pw.write("<h1>Hello, Bob!</h1>"); }else { pw.write("<h1>Hello, world!</h1>"); } pw.flush(); } }
这边才回顾起老师以前讲的一些知识的作用:
1. 字符串不要用`==` 比较
2. 变量可能为null不要放在equals前面会报错
Sign in to make a reply
Best of Me
这边才回顾起老师以前讲的一些知识的作用:
1. 字符串不要用`==` 比较
2. 变量可能为null不要放在equals前面会报错