zoukankan      html  css  js  c++  java
  • 关于jsp页面中接收二维数组

    正确写法

            <%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]="博客题目";指针找不到错误。

  • 相关阅读:
    CVPR顶会热词统计
    @Annotation学习
    把一张表已有的数据对另一张表数据进行修改
    两张表数据不一致进行对比
    学习借鉴
    借鉴tcp
    借鉴tcp
    osi七层
    http学习
    Json学习
  • 原文地址:https://www.cnblogs.com/blunFan/p/11630289.html
Copyright © 2011-2022 走看看