怎么跳回主界面?请看代码<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>Welcome to my W3School</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my W3School">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body >
<center>
<a name="pageTop">href="http://www.w3school.com"
</a>
<img alt="W3School"src="<%=basePath%>img/W3School/logo.jpg"/>
<img alt="Hello,MyFriends" src="<%=basePath %>img/W3School/advert.jpg"/>
</center>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<a href="#pageTop">
回到顶部
</a>
</body>
</html>
这个代码中,我的jsp放在 front/SimpleMain的位置!
现在,我这里想要点击“回到顶部”的时候就回到顶部。但是:我之前
<a href="#pageTop">
回到顶部
</a>
的时候他会到的是index.jsp去了!我一查那个url,发现时http://localhost:8080/HtmlEx/#pageTop.于是,我改成
<a href="<%=basePath %>front/SimpleMain/#pageTop">
回到顶部
</a>于是发生404错误。请问,我该怎么修改 !
【注:回答请注明你的url,这样方便参考】
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>Welcome to my W3School</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my W3School">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body >
<center>
<a name="pageTop">href="http://www.w3school.com"
</a>
<img alt="W3School"src="<%=basePath%>img/W3School/logo.jpg"/>
<img alt="Hello,MyFriends" src="<%=basePath %>img/W3School/advert.jpg"/>
</center>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<p>fdfw</p>
<a href="#pageTop">
回到顶部
</a>
</body>
</html>
这个代码中,我的jsp放在 front/SimpleMain的位置!
现在,我这里想要点击“回到顶部”的时候就回到顶部。但是:我之前
<a href="#pageTop">
回到顶部
</a>
的时候他会到的是index.jsp去了!我一查那个url,发现时http://localhost:8080/HtmlEx/#pageTop.于是,我改成
<a href="<%=basePath %>front/SimpleMain/#pageTop">
回到顶部
</a>于是发生404错误。请问,我该怎么修改 !
【注:回答请注明你的url,这样方便参考】
会给你的地址前默认添加当前WEB应用的路径。。把这句去掉即可。。
我自己解决了,最后改成
<a href="<%=basePath %>front/SimpleMain.jsp#pageTop">
就好了。
首先是多了“/”,
其次是没写.jsp
我自己解决了,最后改成
<a href="<%=basePath %>front/SimpleMain.jsp#pageTop">
就好了。
首先是多了“/”,
其次是没写.jsp