Commit d6679a63 by shj

下载功能在url里接收参数,在历史预算页面提供下载

parent 97b2d07a
...@@ -179,6 +179,30 @@ public class BudgetHandler { ...@@ -179,6 +179,30 @@ public class BudgetHandler {
} }
} }
@RequestMapping("/Download/csv/{budgetid}")
public void downloadCsv(@PathVariable("budgetid") Long budgetid,HttpServletRequest request, HttpServletResponse response, HttpSession session) {
//response.setContentType("application/octet-stream");
response.setContentType("text/html;charset=UTF-8");
String sessionID = budgetid.toString();
try {
Budget budget = retrieveBudget(sessionID);
//writer = response.getWriter();
response.setHeader("content-disposition", "attachment;filename=Budget" + sessionID + ".csv");
assert budget != null;
//budgetToOutputStream(budget, writer);
budgetToOutputStream(budget, response.getOutputStream());
System.out.println("Download...............");
} catch (IOException e) {
e.printStackTrace();
} catch (Throwable e) {
e.printStackTrace();
}
}
@RequestMapping("/Detail") @RequestMapping("/Detail")
public ModelAndView budgetDetailHandler(HttpServletRequest request) { public ModelAndView budgetDetailHandler(HttpServletRequest request) {
String sessionID = getSessionID(request.getCookies()); String sessionID = getSessionID(request.getCookies());
......
...@@ -83,7 +83,12 @@ ...@@ -83,7 +83,12 @@
<button class="btn btn-success">查看详情</button> <button class="btn btn-success">查看详情</button>
</a> </a>
<button class="btn btn-info">修改属性</button> <button class="btn btn-info">修改属性</button>
<button class="btn btn-info">下载说明文件</button> <a v-bind:href="'${pageContext.request.contextPath}/Budget/Download/csv/'+budget.id">
<button class="btn btn-success">下载csv</button>
</a>
<a v-bind:href="'${pageContext.request.contextPath}/Budget/Download/word/'+budget.id">
<button class="btn btn-success">下载word</button>
</a>
<button class="btn btn-danger" @click="del(budget.id)">删除</button> <button class="btn btn-danger" @click="del(budget.id)">删除</button>
</td> </td>
</tr> </tr>
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
</div> </div>
</div> </div>
</nav> </nav>
<%--
<button class="btn btn-success" onclick=jsp()>test</button> <button class="btn btn-success" onclick=jsp()>test</button>
<label id="xxx">123445</label> <label id="xxx">123445</label>
...@@ -91,6 +92,29 @@ ${pageContext.request.contextPath}<br> ...@@ -91,6 +92,29 @@ ${pageContext.request.contextPath}<br>
</tr> </tr>
</table> </table>
</div> </div>
--%>
<div>
<div id="menu">
控制
</div>
<div id="show">展示</div>
</div>
<script type="text/javascript">
var list=$("#show");
var menu=document.getElementById("menu");
list.hide();
menu.onmouseover=function (ev) {
list.show();
};
menu.onmouseleave=function (ev) {
list.hide();
};
</script>
<div id="VueTest"> <div id="VueTest">
<select v-model="num"> <select v-model="num">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment