<%@ 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>My JSP 'index.jsp' starting page</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 page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css"> --> </head> <body> <a href="index.jsp" mce_href="index.jsp">连接 </a><br> </body> </html> //当访问的是action而反馈回来的jsp页面时在此jsp页面中有可能跟句struts版本的不同而存在路径问题因为它是相对于action路径而言的像这个例子这个页面本和index.jsp位于同一目录下但它相对的是action的路径来连接的所有有可能不行(根据struts的版本不同而不同)因此尽量用相对路径