日期:2014-05-17 浏览次数:20691 次
//jsp路径为<%=basePath%>data/test.jsp <%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; //out.println("ok");如果在这里输出,基路径会变为<%=basePath%>data/,所以找不到图片,1 %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> //out.println("ok");如果在这里输出,基路径也会变为<%=basePath%>data/,所以也找不到图片,2 <base href="<%=basePath%>"> //out.println("ok");如果在这里输出,基路径为<%=basePath%>,这样就找得到图片,3 <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>Insert title here</title> </head> <body> <img src="images/1.gif" width="14" height="14"> //图片路径<%=basePath%>images/1.gif </body> </html>