67,515
社区成员
发帖
与我相关
我的任务
分享
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/pdf</mime-type>
</mime-mapping>
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("application/pdf;charset=utf-8");
OutputStream out = response.getOutputStream();
FileInputStream inputStream = new FileInputStream("D:/a.pdf");
FileChannel channel = inputStream.getChannel();
WritableByteChannel channel_out = Channels.newChannel(out);
channel.transferTo(0,channel.size(),channel_out);
out.flush();
out.close();
}