新增系统问题下载
This commit is contained in:
parent
be36d03fce
commit
417cb7e497
|
|
@ -3,6 +3,13 @@
|
||||||
<div class="navbar-header pull-right" >
|
<div class="navbar-header pull-right" >
|
||||||
<!-- <div class="navbar-header pull-right" role="navigation"> -->
|
<!-- <div class="navbar-header pull-right" role="navigation"> -->
|
||||||
<ul class="nav ace-nav">
|
<ul class="nav ace-nav">
|
||||||
|
<!-- 问号图标 -->
|
||||||
|
<li class="light-blue">
|
||||||
|
<a href="javascript:void(0);" onclick="downloadInstructions()" title="常见问题说明">
|
||||||
|
<i class="icon-question-sign nav-icon"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li class="userperLi">
|
<li class="userperLi">
|
||||||
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
|
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
|
||||||
<i class="icon-user nav-user-icon"></i>
|
<i class="icon-user nav-user-icon"></i>
|
||||||
|
|
@ -27,3 +34,11 @@
|
||||||
</li>
|
</li>
|
||||||
</ul><!-- /.ace-nav -->
|
</ul><!-- /.ace-nav -->
|
||||||
</div><!-- /.navbar-header -->
|
</div><!-- /.navbar-header -->
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
// 下载使用说明文件
|
||||||
|
function downloadInstructions() {
|
||||||
|
// 直接跳转到下载接口
|
||||||
|
window.location.href = '${pageContext.request.contextPath}/backstage/index/downloadManual';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
|
|
@ -1,5 +1,12 @@
|
||||||
package com.bonus.sys.controller;
|
package com.bonus.sys.controller;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
@ -26,4 +33,34 @@ public class IndexController {
|
||||||
mv.setViewName("index/mapSpecial");
|
mv.setViewName("index/mapSpecial");
|
||||||
return mv;
|
return mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载系统常见问题手册
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/downloadManual")
|
||||||
|
public void downloadManual(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
// 读取resources/template目录下的文件
|
||||||
|
InputStream inputStream = getClass().getResourceAsStream("/template/系统常见问题手册.docx");
|
||||||
|
|
||||||
|
// 设置响应头
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||||
|
String fileName = URLEncoder.encode("系统常见问题手册.docx", "UTF-8");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||||
|
|
||||||
|
// 将文件内容写入响应输出流
|
||||||
|
OutputStream outputStream = response.getOutputStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len;
|
||||||
|
while ((len = inputStream.read(buffer)) > 0) {
|
||||||
|
outputStream.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭流
|
||||||
|
outputStream.close();
|
||||||
|
inputStream.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue