Discuss / Java / 练习:根据HttpServletRequest文档,调用合适的方法获取URL参数

练习:根据HttpServletRequest文档,调用合适的方法获取URL参数

Topic source

jasmine

#1 Created at ... [Delete] [Delete and Lock User]
String name = req.getParameter("name");
name = name.length() > 0 ? name : "world";
resp.setContentType("text/html");
PrintWriter pw = resp.getWriter();
pw.write("<h1>Hello, "+name+"!</h1>");
pw.flush();

访问地址:http://localhost:8080/hello/?name=bob

问题:不传name参数就500了,还未找到解决方法

🌙

#2 Created at ... [Delete] [Delete and Lock User]

一眼空指针


  • 1

Reply