网址http://localhost:8080/webStore/打开后出现的是正确的结果,但是网址http://localhost:8080/webStore/index.jsp打开后竟然出现了错误的结果。页面都打开了,只是后者的页面与结果不符。高手看看。

解决方案 »

  1.   

    http://localhost:8080/webStore/ 实际访问的可能不是 http://localhost:8080/webStore/index.jsp有可能是http://localhost:8080/webStore/index.html或者其他文件,这个要看你web.xml里面欢迎文件怎么写的了,问题原因估计就是这样
      

  2.   

      <display-name>jstl1.000</display-name>
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
      

  3.   

    web.xml自动生成,我没有改它。
      

  4.   

    http://localhost:8080/webStore/
    回车后
    看看地址栏里的url自动变成什么
      

  5.   

    url没有变,还是http://localhost:8080/webStore/
      

  6.   

    你把欢迎文件改下,或者自己找找
    <display-name>jstl1.000</display-name>
      <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
    这里面有哪个文件,没有问题的页面肯定是上面的除了index.jsp的一个,index.html index.htm啥的你那个index.jsp有问题这是肯定的,即便你找到了另外显示的文件,又有什么用呢还不如找找index.jsp到底什么问题
      

  7.   

    很明显是按照下面的顺序依次查找
     <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
    如果你项目根目录下有index.html和index.htm,那肯定优先是这两个
    要么去掉这两个文件,要么配置的时候将index.jsp的放在上面
      

  8.   

    <%=new java.util.Date().getDay()%>这行代码下面有行黄色的曲线提示。不知道是不是原因呢?
      

  9.   

    把index.jsp贴出来 给你看看哪里有问题就行了,不是这一行
      

  10.   

    <%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*"
        pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GB18030">
    <title>根据当前的星期显示不同的提示信息</title>
    </head>
    <body>
    <!-- 获取星期并保存到变量中 -->
    <c:set var="week">
    <%=new java.util.Date().getDay()%>
    </c:set>
    <c:choose>
    <c:when test="${week==0}">今天是星期日:<br></c:when>
    <c:otherwise>今天是星期<c:out value="${week}"/>:<br></c:otherwise>
    </c:choose>
    <c:choose>
    <c:when test="${week==0 || week==6}">今天是休息日,放松一下心情吧!</c:when>
    <c:when test="${week==1}" >新的一周开始了,努力学习吧!</c:when>
    <c:otherwise>继续努力学习吧!</c:otherwise>
    </c:choose>
    </body>
    </html>
      

  11.   

    <%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*"
      pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GB18030">
    <title>根据当前的星期显示不同的提示信息</title>
    </head>
    <body>
    <!-- 获取星期并保存到变量中 -->
    <c:set var="week">
    <%=new java.util.Date().getDay()%>
    </c:set>
    <c:choose>
    <c:when test="${week==0}">今天是星期日:<br></c:when>
    <c:otherwise>今天是星期<c:out value="${week}"/>:<br></c:otherwise>
    </c:choose>
    <c:choose>
    <c:when test="${week==0 || week==6}">今天是休息日,放松一下心情吧!</c:when>
    <c:when test="${week==1}" >新的一周开始了,努力学习吧!</c:when>
    <c:otherwise>继续努力学习吧!</c:otherwise>
    </c:choose>
    </body>
    </html>
      

  12.   

    <c:set var="week">
    <%=new java.util.Date().getDay()%>
    </c:set>这话有问题吧  week变量要定义的吧
      

  13.   

    <% pageContext.setAttribute("week","");  %>
      

  14.   

    c:set本来就是定义变量的,你这样做就是多此一举
      

  15.   

    我没有发现代码里面什么大的问题,下面的内容在我的环境下跑没有任何问题
    楼主你试试下面代码,看看有没有报错什么的<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*"
      pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>根据当前的星期显示不同的提示信息</title>
    </head>
    <body>
    <!-- 获取星期并保存到变量中   --><c:set var="week" >
    <%=new java.util.Date().getDay()%>
    </c:set>
    <c:choose>
    <c:when test="${week==0}">今天是星期日:<br></c:when>
    <c:otherwise>今天是星期<c:out value="${week}"/>:<br></c:otherwise>
    </c:choose>
    <c:choose>
    <c:when test="${week==0 || week==6}">今天是休息日,放松一下心情吧!</c:when>
    <c:when test="${week==1}" >新的一周开始了,努力学习吧!</c:when>
    <c:otherwise>继续努力学习吧!</c:otherwise>
    </c:choose>
    </body>
    </html>
      

  16.   


    +1你前后两个访问的根本就不是同一个url
    http://localhost:8080/webStore/的实际地址可能是除了index.jsp的任一个。如果前面没找到的话。
    而http://localhost:8080/webStore/index.jsp 是直接去访问index.jsp页面,如果该页面不存在,或路径不正确都会错误
      

  17.   

    我刚才试过了,还是bug的问题,电脑重新启动后竟然可以了。