遇到这样一个问题:
放入jsp代码后,显示404错误。 
这种情况一般是发生在什么状况下?
是jsp代码有错误,还是连接数据库取数据时发生错误,还是其他的原因?
请指教

解决方案 »

  1.   

    位置没对,或者你访问的路径错了,或者是web.xml错了
      

  2.   

    页面没找到,看看跳转的路径和jsp页面放的位置是否一致
      

  3.   

    你可以看一下tomcat运行环境下有没有生成它对应的class文件
      

  4.   

    是没生成class文件,,是不是jsp代码写错了,不能编译?还是其他的原因
      

  5.   

    我是myeclipse中写的,没提示语法的错误,是不是还有其他的什么原因
      

  6.   

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*" errorPage="" %>
    <jsp:directive.page import="com.spring.*"/>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <!-- TemplateBeginEditable name="doctitle" -->
    <title>无标题文档</title>
    <!-- TemplateEndEditable -->
    <!-- TemplateBeginEditable name="head" -->
    <!-- TemplateEndEditable -->
    </head><body>
    <table width="698" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td height="87" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <!--DWLayoutTable-->
          <tr>
            <td width="698" height="87">&nbsp;</td>
          </tr>
        </table>    </td>
      </tr>
      <tr>
        <td width="161" height="2723" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <!--DWLayoutTable-->
          <tr>
            <td width="161" height="2723" valign="top"><div align="center"><strong>新闻分类</strong></div>
              <br />
              <br />
              <%
               FirstTitleOperate fto = new FirstTitleOperate();
               Vector v = fto.getData();
               if(v.size() !=0)
               {
               for(int i = 0 ; i<v.size();i++)
               {
               FirstTitleBean ft =(FirstTitleBean) v.get(i);
              
               %>
               <div align="center"><%=ft.getTitlename() %></div>
              <br />
              <br />
              <%
              }
              }
               %>
              
              </td>
              
          
          </tr>
        </table>    </td>
        <td width="537" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <!--DWLayoutTable-->
          <tr>
            <td width="537" height="2723" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
          </tr>
        </table>
        </td>
      </tr>
    </table>
    </body>
    </html>
    这个是forward.jsp 文件
      

  7.   

     <% 
              FirstTitleOperate fto = new FirstTitleOperate(); 
              Vector v = fto.getData(); 
              if(v.size() !=0) 
              { 
              for(int i = 0 ; i <v.size();i++) 
              { 
              FirstTitleBean ft =(FirstTitleBean) v.get(i); 
              
              %> 
              <div align="center"> <%=ft.getTitlename() %> </div> 
              <br /> 
              <br /> 
              <% 
              } 
              } 
              %> 
    比如说我把以上这段代码删除掉
    在地址栏中输入http://localhost:8080/new/forward.jsp
    没问题,出现   “新闻分类” 字样
    当加上了jsp代码片段后IE就出现了下面的提示:
      无法找到该网页 
                                                            HTTP 404  
       最可能的原因是:
    在地址中可能存在键入错误。 
    当您点击某个链接时,它可能已过期。 
     
       您可以尝试以下操作: 
         重新键入地址。  
     
         返回到上一页。 
     
         转至  并查找您想要的信息。  
     
         更多信息 
     
      

  8.   

    我晕
    问题在这里,应该是你这段代码出错,然后它根据 errorPage="" 跑到错误页面,而你又没配错误页面
    解决方法,去掉这个 errorPage="" 或者配一个错误页面
      

  9.   

    应该是哦,你先照下面改
    if(v != null){   if(v.size() !=0) 
              { 
              for(int i = 0 ; i <v.size();i++) 
              { 
              FirstTitleBean ft =(FirstTitleBean) v.get(i); 
              
              %> 
              <div align="center"> <%=ft.getTitlename() %> </div> 
              <br /> 
              <br /> 
              <% 
              } 
              } }
      

  10.   

    我知道404是肯定是路径错楼主的主要原因是那段JAVA代码出错(500错),然后配了errorPage=“”,然后就跳到错误页面,但楼主又没指定错误页面的地址,所以才报404错误