不是计算机的bug原因,是代码的错误?还是别的原因,高手帮忙看看。 网址http://localhost:8080/webStore/打开后出现的是正确的结果,但是网址http://localhost:8080/webStore/index.jsp打开后竟然出现了错误的结果。页面都打开了,只是后者的页面与结果不符。高手看看。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://localhost:8080/webStore/ 实际访问的可能不是 http://localhost:8080/webStore/index.jsp有可能是http://localhost:8080/webStore/index.html或者其他文件,这个要看你web.xml里面欢迎文件怎么写的了,问题原因估计就是这样 <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> web.xml自动生成,我没有改它。 http://localhost:8080/webStore/回车后看看地址栏里的url自动变成什么 url没有变,还是http://localhost:8080/webStore/ 你把欢迎文件改下,或者自己找找<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到底什么问题 很明显是按照下面的顺序依次查找 <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的放在上面 <%=new java.util.Date().getDay()%>这行代码下面有行黄色的曲线提示。不知道是不是原因呢? 把index.jsp贴出来 给你看看哪里有问题就行了,不是这一行 <%@ 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> <%@ 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> <c:set var="week"><%=new java.util.Date().getDay()%></c:set>这话有问题吧 week变量要定义的吧 <% pageContext.setAttribute("week",""); %> c:set本来就是定义变量的,你这样做就是多此一举 我没有发现代码里面什么大的问题,下面的内容在我的环境下跑没有任何问题楼主你试试下面代码,看看有没有报错什么的<%@ 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> +1你前后两个访问的根本就不是同一个urlhttp://localhost:8080/webStore/的实际地址可能是除了index.jsp的任一个。如果前面没找到的话。而http://localhost:8080/webStore/index.jsp 是直接去访问index.jsp页面,如果该页面不存在,或路径不正确都会错误 我刚才试过了,还是bug的问题,电脑重新启动后竟然可以了。 没有为参数号 5 设置值。 求Ext.toolbar鼠标移开隐藏menu,麻烦各位高人帮帮忙,困扰2天了。 java???HttpClient???? 关于网站侵权方面 请帮忙把下面一段标签翻译成JAVA 在Eclipse里package hello;老是变成红色的X号。为什么? 我的jsp服务器报这个错误,请问题怎么处理,谢谢各位大侠,帮帮小弟这个新手, JdonFramework是什么东东? JavaWeb文件管理器 spring 文件下载 画图啊,烦死啦、、、、、 帮我找找网站的源代码,各位收藏的好代码能共享一下吧
<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>
回车后
看看地址栏里的url自动变成什么
<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到底什么问题
<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的放在上面
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>
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>
<%=new java.util.Date().getDay()%>
</c:set>这话有问题吧 week变量要定义的吧
楼主你试试下面代码,看看有没有报错什么的<%@ 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>
+1你前后两个访问的根本就不是同一个url
http://localhost:8080/webStore/的实际地址可能是除了index.jsp的任一个。如果前面没找到的话。
而http://localhost:8080/webStore/index.jsp 是直接去访问index.jsp页面,如果该页面不存在,或路径不正确都会错误