我如何在jsp页面的动态选择框中显示2D数组的结果

时间:2018-09-24 09:34:19

标签: java jsp

我正在从我的jsp页面调用两个方法,该方法返回一个字符串和一个2dArray。我有三个选择框,其中一个必须显示方法返回的单个字符串值,其他两个选择框我有一个2dArray该值我必须显示它们。我在我的jsp页面中返回方法,并且我想显示结果,但是每次我都低于异常。下面是我的代码

 try {
User user=  new User();
int userIdAppsFnd = Integer.parseInt(System.getProperty("userIdFromAppFnd"));  
String result = null;
boolean isRMAEXTUSERUpdateSuccess = false;
boolean isRMAQueueUserUpdate = false;
//********************** update details into cav_rmaext_users table and cav_rmaext_quers ********************//
if(userIdAppsFnd !=0 && !Role[0].equals(""))
roleOfUser = user.updateRMAEXTUsers(userIdAppsFnd,Role[0]);

if(roleOfUser.equalsIgnoreCase("QA") || roleOfUser.equalsIgnoreCase("CSR")|| roleOfUser.equalsIgnoreCase("FAE")){

    isRMAQueueUserUpdate = user.updateRMAQueueUserUpdate(userIdAppsFnd,Role[0]);
    //*********************   insert details into admin lookup Table ********************************************//
    if(isRMAQueueUserUpdate){
        r[][] = user.insertIntoAdminLookUp(Domain,Flag);
    }
    System.out.println("result is :"+result);
}
//**********************************************************************************************************//
if(result.equals("Success")){
    request.setAttribute("Information Successfully Added", message);
    response.sendRedirect("admin.jsp?roleOfUser="+roleOfUser);
}else if(result.equals("Fail")){
    request.setAttribute("Problem occured in adding Information", message);
    response.sendRedirect("admin.jsp");
}
} catch (Exception e) {
   e.printStackTrace();
 }

首先选择框

<td align="left"><span class="x3x">
 Assign&nbsp;Role:&nbsp;&nbsp;&nbsp;</span>
<select style="width:90px" id="Role" name="Role">
<option value="">--Select--</option>
   <!-- <option value="QA">QA</option> -->
    <option value="QA"  <%if((roleOfUser)=="QA"){%> selected <%}%> >QA</option>
  <option value="CSR">CSR</option>
 <option value="FAE">FAE</option>
 </select>

第二个是动态选择框

   <tr>
  <td align="center" valign="top">
  <table id="ItemDetail" class ="order-list" width="320" align="center" border="1" cellspacing="0" cellpadding="0">
   <tr>
  <td width="170" class='CAVHD'>Restricted Domain</td>
<td width="160" class='CAVHD'>Enable Flag</td>
</tr>
<tr id="row_1">
<td class='CAVRW'><input width="250" type="text" class='STDTXTMND' id="Domain_1" name="Domain_1"></td>
<td class='CAVRW'><select class='STDTXTMND' id="Flag_1" name="Flag_1">
  <option value="Y">Yes</option>
  <option value="N" >SELECTED>No</option>
  </select></td>
  </tr>
  </table>
   </td></tr>

以及以下异常

java.lang.NullPointerException
at org.apache.jsp.admin_jsp._jspService(admin_jsp.java:107)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(Standard

请帮助。

0 个答案:

没有答案