jsp 网页计数器的简单问题
这是jsp的代码文件路径也对就是网页上不显示计数的图片是怎么回事?<%@pagelanguage="java"import="java.util.*"pageEncodi...
这是jsp的代码 文件路径也对 就是网页上不显示计数的图片是怎么回事?
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
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">
-->
<%@ page import="jishu.*" %>
</head>
<body>
<%
shuju read=new shuju();
String number=""+read.getCount();
%>
<h1>net count</h1>
<hr>
hello you are the
<%
for(int i=0;i<number.length();i++){
out.print("<img src='C:/Users/lq/Desktop/5/"+number.charAt(i)+".GIF'>");
}
%>
request
</body>
</html> 展开
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
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">
-->
<%@ page import="jishu.*" %>
</head>
<body>
<%
shuju read=new shuju();
String number=""+read.getCount();
%>
<h1>net count</h1>
<hr>
hello you are the
<%
for(int i=0;i<number.length();i++){
out.print("<img src='C:/Users/lq/Desktop/5/"+number.charAt(i)+".GIF'>");
}
%>
request
</body>
</html> 展开
2013-10-07
展开全部
那肯定不行了,因为你web服务器(tomacat或者apache)解析的范围不包括你的图片位置所在。最简单的办法就是,在项目根目录新建一个存放图片的文件夹比如:images,然后将你计数所用的图片都放在这个文件夹下就行了。
然后修改成: out.print("<img src="images/"+number.charAt(i)+".GIF'>");即可。
然后修改成: out.print("<img src="images/"+number.charAt(i)+".GIF'>");即可。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询