无法从 JSP 页面中的 Bean 调用 getNames()...成功设置名称,但是当我调用 getNames 时它返回 Null
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
List<String> name=new ArrayList<String>();
name.add("Pushkar");
name.add("Raj");
ArrayBean bean=new ArrayBean();
bean.setNames(name.toArray(new String[name.size()]));
// request.getRequestDispatcher("DDL.jsp").forward(request, response);
response.sendRedirect("DDL.jsp");
} finally {
out.close();
}
public class ArrayBean {
public String[] names;
public String[] getNames() {
return names;
}
public void setNames(String[] names) {
this.names = names;
}
}