写了一个servlet,可以返回一个图片,也可以返回一个数字
对于前者在html页面中使用 <img src="http://127.0.0.1/serv?a=1">即可在页面中显示出来
对于后者怎么写呢?
http://127.0.0.1/serv?a=2,在页面中显示的是这个地址,而不是返回的数字结果。 怎么办?
对于前者在html页面中使用 <img src="http://127.0.0.1/serv?a=1">即可在页面中显示出来
对于后者怎么写呢?
http://127.0.0.1/serv?a=2,在页面中显示的是这个地址,而不是返回的数字结果。 怎么办?
request.setAttribute("url","http://127.0.0.1/serv?a=2");然后在转向的页面里写<img src="+${requestScope.url}+">
你在JAVA后台存的就是图片的地址~·
你不是说对于前者在html页面中使用 <img src="http://127.0.0.1/serv?a=1">即可在页面中显示出来我1楼的方法就是这意思
<script>
window.onload=function(){
document.getElementById("pad").innerHTML = document.getElementById("hf").contentWindow.document.body.innerHTML;
}
</script>
<span id="pad"></span>
<iframe id="hf" src="http://127.0.0.1/serv?a=2" style="display:none"></iframe>