jspsmart很多人都用过,高手也是如云滴多,网上资料更是漫天飞,不过对于我这个新手菜鸟,将文件的上传下载坐下来,感触还是很深的,有很多东西需要在这里沉淀下来。为了自己,也为了像我一样的菜鸟。
如果不想走后台action,直接使用jsp来完成文件的上传下载,jspsmart是最好的工具了。这里我就开始才从文件的上传开始讲起吧!
1、在网上下载一个jspsmart.jar,并放入工程的classpath下,这里就不细说了。
2、为了实现文件上传页面不跳转的功能,我这里在页面中添加了一个iframe,iframe中引入另外一个jsp,这个jsp中包含一个form,如下iframe的内容:
<iframe src="<%=path%>/service/communication/bulletinIssueAttach.jsp" name="attach" width="680" height="80" scrolling="no"
frameborder="0" align="left" >
</iframe>
在bulletinIssueAttach.jsp中存在一个form,form的内容很简单就是一个file类型的控件,内容如下:
<body>
<div class="right_middle_function">
<div class="content_step1" style="border: none;margin: 0px;">
<table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="

本文介绍了如何利用jspsmart在jsp页面中实现文件上传而无需跳转到新页面。通过在页面中添加iframe,创建包含file控件的form,然后在目标jsp中处理上传逻辑,可以实现文件上传后页面不跳转的效果。同时强调了设置contentType为UTF-8以避免中文名乱码的重要性,并提供了jspsmart的相关API参考链接。
最低0.47元/天 解锁文章
453

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



