下面这段源码 保存为.html的文件浏览图片的时候就可以 看到 图片,可是将主要的代码加到 .jsp页面里面 图片就 无法显示缩图,请高手指点啊!!!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>档案添加</title>
<link href="../css/body.css" rel="stylesheet" type="text/css" />
<script language="javascript" >function dothis(){
document.getElementById("myimg").src = document.getElementById("abc").value;
}
function dothis1(){
document.getElementById("myimg").src = "";}

</script>
</head>
<body>
<div style="height:30px; width:200px; border:#CCCCCC 1px solid; float:left;">
<input type="button" class="buttonI" value="查找照片" onmousemove="abc1.style.pixelLeft=event.x-60;abc.style.pixelTop=this.offsetTop;"  onclick="abc.click()"/>
<input type="file" id="abc" onChange="dothis()" name="abc1" style="position:absolute;filter:alpha(opacity=0);" size="1" hidefocus>
<input type="button" class="buttonI" value="清除照片" onclick="dothis1()"/>
</div>
<div style="height:170px; width:200px; border:#CCCCCC 1px solid; float:left; clear:both;">
<img id="myimg" src="" style="width:100%; height:100%;"/>
</div>

</body>
</html>

解决方案 »

  1.   

    jsp里面也要进行相应的编码才行
      

  2.   

    <%@ 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 'aa.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">
    -->
    <script type="text/javascript">
    function dothis(){ 
    document.getElementById("myimg").src = document.getElementById("abc").value; 

    function dothis1(){ 
    document.getElementById("myimg").src = "";

    </script>
    </head> <body>
    <div
    style="height: 30px; width: 200px; border: #CCCCCC 1px solid; float: left;">
    <input type="button" class="buttonI" value="查找照片"
    onmousemove="abc1.style.pixelLeft=event.x-60;abc.style.pixelTop=this.offsetTop;"
    onclick="abc.click()" />
    <input type="file" id="abc" onChange="dothis()" name="abc1"
    style="position: absolute; filter: alpha(opacity = 0);" size="1"
    hidefocus>
    <input type="button" class="buttonI" value="清除照片" onclick="dothis1()" />
    </div>
    <div
    style="height: 170px; width: 200px; border: #CCCCCC 1px solid; float: left; clear: both;">
    <img id="myimg" src="" style="width: 100%; height: 100%;" />
    </div>
    </body>
    </html>我在jsp下也可以啊!
      

  3.   

    刚才把工程提交了下,让我的同事在他的电脑上测试了下我的那个页面,结果在他的电脑上可以显示,而我的就不可以、、、、
    哎!
    只不过他的IE是6.0的,我的IE7 ,但是我觉得应该与他无关,要不为什么我的.html的可以显示呢?
    那位大侠知道原因呢?