protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head></head>");
out.println("<body>");
String err[]=(String[]) request.getAttribute("error");
*
字符串的错误数组是从下一页发送并在这一页中接收的。但是,如果我尝试在此位置使用与下面给出的相同代码放置 for 循环,那么即使我可以的表单字段也不会显示不明白为什么我使用 Netbeans Ide 并且 servlet 的名称是:-form,addLeague nad success
*
out.println("<form action=addLeague method=post>");
out.println("name: <input type='text' name='name'>");
out.println("Season: <input type='text' name='season'>");
out.println("year <input type='text' name='year'>");
out.println("submit:<input type='submit' value='save'>");
out.println("</form>");
for(int i=0;i<=3;i++)
{
if(err[i]!=null)
out.println("<h1>"+err[i]+"</h1>");
}
out.println("</body>");
out.println("</html>");
}
catch(Exception e)
{
}
finally {
out.close();
}
}