正确写法

        <%String[][] blog = new String[5][];
        blog[0] = request.getParameterValues("blog0"); 
        blog[1] = request.getParameterValues("blog1");
        blog[2] = request.getParameterValues("blog2"); 
        blog[3] = request.getParameterValues("blog3");
        blog[4] = request.getParameterValues("blog4"); 
        for(int i=0;i<blog.length;i++){
            if(blog[i]==null){
                blog[i]=new String[5];
                blog[i][0]="博客题目";
                blog[i][1]="博客分类";
                blog[i][2]="博客时间";
                blog[i][3]="博客前80字";
            }
        %>

不能写作

        <%String[][] blog = new String[5][5];
        blog[0] = request.getParameterValues("blog0"); 
        blog[1] = request.getParameterValues("blog1");
        blog[2] = request.getParameterValues("blog2"); 
        blog[3] = request.getParameterValues("blog3");
        blog[4] = request.getParameterValues("blog4"); 
        for(int i=0;i<blog.length;i++){
            if(blog[i]==null){
                blog[i][0]="博客题目";
                blog[i][1]="博客分类";
                blog[i][2]="博客时间";
                blog[i][3]="博客前80字";
            }
        %>

否则会报

Stacktrace:] with root cause
java.lang.NullPointerException

即blog[i][0]="博客题目";指针找不到错误。

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2021-12-30
  • 2022-03-02
  • 2021-12-28
  • 2022-12-23
  • 2021-07-29
  • 2021-10-12
猜你喜欢
  • 2021-08-05
  • 2021-12-12
  • 2022-01-26
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
相关资源
相似解决方案