首页 > 其他 > 详细

发送短信并存入短信库

时间:2014-02-12 01:18:10      阅读:286      评论:0      收藏:0      [点我收藏+]
一、背景
用户上传了一张图片,图片到服务器后用户得到一个链接,可以将图片显示在浏览器上。

二、实现
假设项目名叫TestProject,文件放在项目根目录下的uploadImages文件夹下。
①图片名为英文,可直接通过链接打开图片
<a href="http://localhost:8080/TestProject/uploadImages/myImage.jpg">预览图片</a>

②图片名含有中文,通过Servlet将图片输出到浏览器上,使用图片在服务器上的绝对路径
showImage.jsp
<a href="/TestProject/showImageServlet?filename=测试的图片一枚.jpg">预览图片</a>

showImageServlet
public void showImage(HttpServletRequest request, HttpServletResponse response) throws Exception
{
response.setContentType("text/html; charset=UTF-8");
response.setContentType("image/jpeg");
String fname = request.getParameter("filename");
String newpath = new String(fname.getBytes("ISO-8859-1"), "UTF-8");
String absolutePath = rootPath + newpath;
FileInputStream fis = new FileInputStream(absolutePath);
OutputStream os = response.getOutputStream();
try
{
int count = 0;
byte[] buffer = new byte[1024 * 1024];
while ((count = fis.read(buffer)) != -1)
os.write(buffer, 0, count);
os.flush();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (os != null)
os.close();
if (fis != null)
fis.close();
}
}

发送短信并存入短信库

原文:http://blog.csdn.net/u010142437/article/details/19084193

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!