HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: String index out of range: -112438
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.jdon.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:92)
root cause java.lang.StringIndexOutOfBoundsException: String index out of range: -112438
java.lang.String.checkBounds(String.java:283)
java.lang.String.<init>(String.java:319)
xiaoxiang.fileUpload.upBean.upload(upBean.java:178)
org.apache.jsp.qsecofrSystem.Cpxxsave_jsp._jspService(Cpxxsave_jsp.java:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.jdon.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:92)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.
--------------------------------------------------------------------------------Apache Tomcat/5.0.30
<%@ page contentType="text/html; charset=gb2312" language="java" import="com.fredck.FCKeditor.*,java.sql.*,java.util.Date,java.text.SimpleDateFormat" errorPage="" %>
<%@page import="java.util.*,org.spring.dao.factory.DaoFactory" %>
<%@ include file="../golbal/connection.jsp"%>
<%@page import="net.xcsweb.manager.*" %>
<%@page import="net.xcsweb.definevariable.* , org.spring.jdbc.core.DateAccessException"  %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript" type="text/javascript" src="../js/System_cpxx.js"> </script><title></title>
<link href="../css/public.css" rel="stylesheet" type="text/css">
</head><body>
<%
String content="";
String content1="";
String userid=(String)session.getAttribute("userid");
String name=(String)session.getAttribute("name");
String event=request.getParameter("event");
String ctype="";
String nid ="";
if(event.equals("add")){
nid=request.getParameter("nid");}
if(event==null)  event=""; //CpxxsaveManager data = new CpxxsaveManager();
 
 String id = "";
 String id1 = "";
 String mid = "";
 String type = "";
 String type1 = "";
 String type2 = "";
 String type3 = "";
 String type4 = "";
 String title = "" , filename="", check_gg="" , check_gz="" ,check_dg="" ,check_pf="" ,check_tc="" ,check_tt="" ,check_fy="" ,check_fc="" ;
 
 CpxxsaveManager Cpxxsave = new CpxxsaveManager();
 
  if(event.equals("modi")){
id=request.getParameter("id"); List list=Cpxxsave.getSec(id);
  Iterator iterator= list.iterator();
   while(iterator.hasNext()){
Cpxxsave data=(Cpxxsave)iterator.next();
id1=data.getId();

type=data.getType();
type1=data.getType1();
type2=data.getType2();
type3=data.getType3();
type4=data.getType4();
title=data.getTitle();
filename=data.getFilename();
content=data.getContent();
check_gg=data.getCheck_gg();
check_gz=data.getCheck_gz();
check_dg=data.getCheck_dg();
check_pf=data.getCheck_pf();
check_tc=data.getCheck_tc();
check_tt=data.getCheck_tt();
check_fy=data.getCheck_fy();
check_fc=data.getCheck_fc();

}   }%><table width="96%" border="0" align="center" cellspacing="0">
      <tr>
        <th width="100%" height=48><span class="style2"><%if(event.equals("add")) out.print(ctype); else out.print(type);%></span></th>
      </tr>
      <tr> </tr>
      <tr>
        <td class="forumRow">
                      <table width="100%" border="1" align="center" cellspacing="0" bordercolorlight="#739cc6" bordercolordark="#FFFFFF">
<form action="Cpxxsave.jsp" method="post" name="form" onSubmit="return check()" enctype="multipart/form-data" >
              <tr>
                <td bgcolor="#bfd9ff" width="15%"><div align="center"><span class="style1">分类:</span></div></td>
                <td width="85%">
<table width="100%" border="0" cellspacing="0">
<%if(event.equals("add")&&nid.equals("1")){%>
  <tr>
          <td><select name="type1" id="type1" onChange="changepro('type2','type1');">
              <option value="" selected>请选择</option>
              <option value='a'>a</option>
              <option value='b'>b</option>
              <option value='c'>c </option>
  <option value='d'>d</option>
  <option value='e'>e</option>
          </select></td>
   <td><select name="type2" id="type2" onChange="changecity('type3','type2');">
              <option value="">请选择</option>
          </select></td>
    <td><select name="type3" id="type3" onChange="changecity1('type4','type3');">
              <option value="">请选择</option>
          </select></td>
          <td><select name="type4" id="type4" onChange="changecity2('type5','type4');">
              <option value="">请选择</option>
          </select>   </td>
          <td></td>
        </tr>

<%}else if(event.equals("add")&&nid.equals("2")){%>
<%}else if(event.equals("add")&&nid.equals("3")){%>
<%}else{%>
<%}%>
</table>
</td>
              </tr>
  <tr>
                <td bgcolor="#bfd9ff"><div align="center"><span class="style1">名称:</span></div></td>
                <td width="570"><input name="title" type="text" class="txtinput" id="title" size="45" value="<%=title%>">
<input type="hidden" name="type" value="<%=ctype%>">
<input type="hidden" name="userid" value="<%=userid%>">
<input type="hidden" name="event" value="<%=event%>">
<input name="id" type="hidden" id="event" value="<%=id%>">
<input name="nid" type="hidden" id="event" value="<%=nid%>">
<input type="hidden" name="file_1" value="<%=filename%>">

</td>
              </tr>
              <tr>
                <td bgcolor="#BFD9FF"><div align="center"><span class="style1">说明:</span></div></td>
                <td>
<%
  FCKeditor oFCKeditor ;
  oFCKeditor = new FCKeditor( request, "content" ) ;
  oFCKeditor.setBasePath("/xcs/FCKeditor/") ;
  oFCKeditor.setToolbarSet("Basic");
  oFCKeditor.setHeight("150");
  oFCKeditor.setValue(content); 
  out.println( oFCKeditor.create() ) ;
%>
</td>
              </tr>
  <tr>
                <td bgcolor="#BFD9FF"><div align="center"><span class="style1">胎别信息:</span></div></td>
                <td><table width="99%"  border="1" align="center" cellspacing="0" bordercolorlight="#739cc6" bordercolordark="#FFFFFF" class="txtfont">
  <tr bgcolor="#bfd9ff" height="15">
    <td width="12%" bgcolor="#bfd9ff"><div align="center">      <input name="check_gg" type="checkbox" id="check_gg" value="" >a</div></td>
<td width="12%" bgcolor="#bfd9ff"><div align="center"><input name="check_gz" type="checkbox" id="check_gz" value="" >
  b</div></td>
<td width="12%" bgcolor="#bfd9ff"><div align="center"><input name="check_dg" type="checkbox" id="check_dg" value="" >
  c</div></td>
    <td width="12%" height="21"><div align="center"><input name="check_pf" type="checkbox" id="check_pf" value="" >
      d</div></td>
    <td width="12%" nowrap><div align="center"><input name="check_tc" type="checkbox" id="check_tc" value="" >
      e)</div></td>
    <td width="12%" bgcolor="#bfd9ff"><div align="center"><input name="check_tt" type="checkbox" id="check_tt" value="" >
      f</div></td>
    <td width="12%" height="21"><div align="center"><input name="check_fy" type="checkbox" id="check_fy" value="" >
      g</div></td>
        <!--<td width="37"><div align="center">删除</div></td>-->
  </tr>
</table>

</td>
              </tr>
              <tr>
                <td bgcolor="#BFD9FF"><div align="center"><span class="style1">图片上传:</span></div></td>
                <td><table width="100%"  border="0" cellspacing="0" class="txtfont">
                    <tr>
            <td>
<input name="file1" type="file" id="file1" class="txtinput7" size="40" onChange="viewmypic(showimg,this.form.file1);" />
<input name="file2" type="file" id="file2" class="txtinput7" size="40" onChange="viewmypic1(showimg1,this.form.file2);" />
<input name="file3" type="file" id="file3" class="txtinput7" size="40" onChange="viewmypic2(showimg2,this.form.file3);" />  </td>
          </table></td>
              </tr>
              <tr>
                <td colspan="2">            <div align="center">
              <input name="Submit" type="submit" class="but" id="Submit" style="cursor:hand;" value="提 交">
              <input name="reset1" type="reset" class="but" style="cursor:hand;" value="重 置">
            </div></td>
              </tr>
  </form>
          </table>        </td>
      </tr>
</table>
</body>
</html>

解决方案 »

  1.   


    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <%@ include file="../golbal/connection.jsp"%><%@ page import="xiaoxiang.fileUpload.*"%>
    <%@ page import="java.util.Date,java.text.SimpleDateFormat"%>
    <!-- 初始化一个upBean-->
    <jsp:useBean id="myUpload" scope="page" class="xiaoxiang.fileUpload.upBean" /><%
     myUpload.initialize(pageContext);
     myUpload.setIsCover(false);
     myUpload.setTotalMaxFileSize(25000000);
     String[] sourceName={"","","","",""};
     String myName=new String("");
     myUpload.setRealPath(application.getRealPath("upload/Cpxx"));
     try
     {
       myUpload.upload();
     }
     catch(Exception e){throw e;}
     files myFiles=myUpload.getFiles();

          String type=myUpload.getRequest().getParameter("type");
      if(type==null)  type="";
         String type1=myUpload.getRequest().getParameter("type1");
      if(type1==null)  type1="";
         String type2=myUpload.getRequest().getParameter("type2");
      if(type2==null)  type2="";
         String type3=myUpload.getRequest().getParameter("type3");
      if(type3==null)  type3="";
         String type4=myUpload.getRequest().getParameter("type4");
      if(type4==null)  type4="";
         String title=myUpload.getRequest().getParameter("title");
      if(title==null)  title="";
      
       String file_1=myUpload.getRequest().getParameter("file_1");
      if(file_1==null)  file_1="";
      
         String content=myUpload.getRequest().getParameter("content");
      if(content==null)  content="";
         String content1=myUpload.getRequest().getParameter("content1");
      if(content1==null)  content1="";
         String check_gg=myUpload.getRequest().getParameter("check_gg");
      if(check_gg==null)  check_gg="0"; else  check_gg="1";
         String check_gz=myUpload.getRequest().getParameter("check_gz");
      if(check_gz==null)  check_gz="0"; else  check_gz="1";
         String check_dg=myUpload.getRequest().getParameter("check_dg");
      if(check_dg==null)  check_dg="0"; else  check_dg="1";
         String check_pf=myUpload.getRequest().getParameter("check_pf");
      if(check_pf==null)  check_pf="0"; else  check_pf="1";
         String check_tc=myUpload.getRequest().getParameter("check_tc");
      if(check_tc==null)  check_tc="0"; else  check_tc="1";
         String check_tt=myUpload.getRequest().getParameter("check_tt");
      if(check_tt==null)  check_tt="0"; else  check_tt="1";
         String check_fy=myUpload.getRequest().getParameter("check_fy");
      if(check_fy==null)  check_fy="0"; else  check_fy="1";
         String check_fc=myUpload.getRequest().getParameter("check_fc");
      if(check_fc==null)  check_fc="0"; else  check_fc="1";   
         
     String userid=myUpload.getRequest().getParameter("userid");
     String event=myUpload.getRequest().getParameter("event");
     SimpleDateFormat df1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
     String bh1=df1.format(new Date());
    String fileStr="";
    try {   
     for(int i=0;i<myFiles.getCount();i++)
     {
    myName=new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
    myName=myName+i+"."+myFiles.getFile(i).getExtName();
    sourceName[i]=myFiles.getFile(i).getName();
    //files f = myFiles.getFile(i); 
    //System.out.println(myFiles.getFile(i).getNumber());
    fileStr=fileStr+myName+";";
    myFiles.getFile(i).setName(myName);
    myFiles.getFile(i).saveAs();
    }
       }
    catch (Exception e) {throw e;}
    %>
    <% if(event.equals("add"))
    {
     sql="INSERT INTO dfr (type, type1, type2, type3, type4, title, content, content1, filename, addid, addtime, Url_id,"+
        "check_gg, check_gz, check_dg, check_pf, check_tc, check_tt, check_fy, check_fc) VALUES ('"+type+"','"+type1+"','"+type2+"','"+type3+"','"+type4+"','"+title+"','"+content+"','"+content1+"','"+fileStr+"','"+userid+"','"+bh1+"','','"+check_gg+"','"+check_gz+"','"+check_dg+"','"+check_pf+"','"+check_tc+"','"+check_tt+"','"+check_fy+"','"+check_fc+"')";  try{
        stmt.execute(sql);
        out.println("<script>alert('新增成功!');window.location='a.jsp';</script>");
      }catch(Exception e){
       out.println("<script>alert('新增失败!"+e+"');window.history.go(-1);</script>");
      }  
      }if(event.equals("modi"))
    {
    String id=myUpload.getRequest().getParameter("id");
    if(id==null)  id="";
    if(fileStr.equals("")){fileStr=file_1;}
     sql="UPDATE dfr SET title ='"+title+"', content ='"+content+"' ,filename ='"+fileStr+"', check_gg ='"+check_gg+"', check_gz ='"+check_gz+"', check_dg ='"+check_dg+"', check_pf ='"+check_pf+"', check_tc ='"+check_tc+"', check_tt ='"+check_tt+"', check_fy ='"+check_fy+"', check_fc ='"+check_fc+"' where id='"+id+" '";
    // System.out.println(sql);
     try{
         stmt.executeUpdate(sql);
    %>  
         <script>alert('修改成功!');window.location='a.jsp';</script>
    <%
    }
     catch(Exception e){
    %> 
         <script>alert('修改失败!"+<%=e%>+"');window.history.go(-1) </script>
    <%  
      }
     } 
    %>SOS,搞了二天没找到原因,大家看一下,这个错误是怎么回事的!先谢谢了!
      

  2.   

    java.lang.StringIndexOutOfBoundsException: String index out of range
    看提示是 字符串数组越界
      

  3.   

    这里xiaoxiang.fileUpload.upBean.upload(upBean.java:178) 往下看
      

  4.   

    同上
    org.apache.jsp.qsecofrSystem.Cpxxsave_jsp._jspService(Cpxxsave_jsp.java:106) 应该是Cpxxsave.jsp 编译成Cpxxsave_jsp.java  的106行
      

  5.   

    java.lang.StringIndexOutOfBoundsException: String index out of range: -112438 下标越界了
      

  6.   

    楼主
    java.lang.StringIndexOutOfBoundsException: String index out of range: -112438 下标越界了了哦,看看xiaoxiang.fileUpload.upBean.upload(upBean.java:178)这个类中的178行,源代码贴上来看看才知道。