在jsp中点击前往按钮弹出提示框,点确认前往相应页面,点取消留在本页面怎么写。请各位大神指教指教谢谢
展开全部
jsp页面代码:
<head>
<script type="text/javascript">
function exportUser() {
$("#method").val("exportUser");
}
</script>
</head>
<body>
<form action="<c:url value='/UserManageServlet' />" method="post" id="userList_form">
<input type="hidden" name="method" value="" id="method">
<button type="submit" class="editBtn" value="exportUser" onclick="javascript:exportUser();">批量导出</button>
</form>
</body>
servlet中代码:
@WebServlet("/UserManageServlet")
public class UserManageServlet extends BaseServlet{
public String exportUser(HttpServletRequest request, HttpServletResponse response) throws Exception{
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=test.txt");
ServletOutputStream sos = response.getOutputStream();
sos.write("Life Is a Test. It Is Only a Test");//这里可以从输入流中得到数据然后写到指定文件中
sos.flush();
sos.close();
}
}
<head>
<script type="text/javascript">
function exportUser() {
$("#method").val("exportUser");
}
</script>
</head>
<body>
<form action="<c:url value='/UserManageServlet' />" method="post" id="userList_form">
<input type="hidden" name="method" value="" id="method">
<button type="submit" class="editBtn" value="exportUser" onclick="javascript:exportUser();">批量导出</button>
</form>
</body>
servlet中代码:
@WebServlet("/UserManageServlet")
public class UserManageServlet extends BaseServlet{
public String exportUser(HttpServletRequest request, HttpServletResponse response) throws Exception{
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=test.txt");
ServletOutputStream sos = response.getOutputStream();
sos.write("Life Is a Test. It Is Only a Test");//这里可以从输入流中得到数据然后写到指定文件中
sos.flush();
sos.close();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询