方法1 这是后台解决 但是只能查看pdf
@RequestMapping("/showPdf")
public void showPdf(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
response.setContentType("application/pdf");
FileInputStream in;
OutputStream out;
try {
in = new FileInputStream(new File(GlobalSetting.get(GlobalSettingNames.MEANS_URL_JCZL) + File.separator + request.getParameter("filename")));
out = response.getOutputStream();
byte[] b = new byte[512];
while ((in.read(b)) != -1) {
out.write(b);
}
out.flush();
in.close();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
方法2 还有tomcat下server.xml配置 路径映射解决 (前端解决)
<Context docBase="C:/data" path="/data" reloadable="true" />
把C:/data/menas/jc/xxx.doc路径映射成 localhost:8080/data/menas/jc/xxx.doc