public class Relay extends HttpServlet {
@Override
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String command = request.getParameter("command");
RequestDispatcher rd =request.getRequestDispatcher(command);
rd.forward(request, response);
System.out.println("Request forwarded to " + command + " servlet");
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的接力服务员,我发送日期
<form action="Relay" method="POST" enctype="multipart/form-data"> /
<input type="hidden" name="command" value="AddProduct" />
<input type="text" name="pname" value="" />
<input name="" type="submit" value="Add Product">
</form>
Run Code Online (Sandbox Code Playgroud)
它给出了java.lang.NullPointerException.enctype ="multipart/form-data"//当我删除它的工作正常