采用servlet 和 jsp 包含 html 和 图片 的文件 显示,代码如下:
显示html 文件:
sevlet 代码:
jsp 代码:
显示图片 文件:
sevlet 代码:
jsp 代码:
显示html 文件:
sevlet 代码:
String htmlFilePath = "./file" + htmlName;
request.getSession().setAttribute("htmlFilePath", htmlFilePath );jsp 代码:
String htmlFilePath= (String)session.getAttribute("htmlFilePath");
<jsp:include page="<%=htmlFilePath %>"></jsp:include>显示图片 文件:
sevlet 代码:
String imgPath = "./file" + imgName;
request.getSession().setAttribute("imgPath ", imgPath );jsp 代码:
String imgPath= (String)session.getAttribute("imgPath");
<img src='<%=imgPath>'></img>
本文介绍了如何使用Servlet和JSP来显示HTML和图片文件。通过设置请求属性并在JSP中使用<jsp:include>标签包含HTML文件,以及直接在JSP中使用<img>标签显示图片。
1707

被折叠的 条评论
为什么被折叠?



