免费获取
|
论文天下网
|
原创毕业论文
|
论文范文
|
论文下载
|
计算机论文
|
论文降重
|
毕业论文
|
外文翻译
|
免费论文
|
开题报告
|
心得体会
|
全站搜索
当前位置:
论文天下网
->
免费论文
->
计算机论文
施工监察系统设计与开发(三)
/**
*
* @param response
* @param returnFile
* 导出的文件
* @param uploadedFileName
* 下载名称
*/
public static void downLoadData(HttpServletResponse response,
File returnFile, String uploadedFileName) {
response.setHeader(" Content-Type", " application/octet-stream");
response.setHeader("Content-Transfer-Encoding", "binary");
response.setHeader("Cache-Control",
"must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
try {
response.setHeader(" Content-disposition", "attachment;filename="
+ URLEncoder.encode(uploadedFileName, "utf8"));
response.setHeader("Content-Disposition", "inline; filename="
+ URLEncoder.encode(uploadedFileName, "utf8"));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(returnFile));
bos = new java.io.BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
try {
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
} catch (IOException e) {
System.out.println("取消下载!");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bis != null)
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
if (bos != null)
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
// 支持在线打开文件的一种方式
public static void downLoadByGYL(String filePath,
HttpServletResponse response, boolean isOnLine) {
File f = new File(filePath);
try {
if (!f.exists()) {
response.sendError(404, "File not found!");
return;
}
BufferedInputStream br = new BufferedInputStream(
new FileInputStream(f));
byte[] buf = new byte[1024];
int len = 0;
response.reset(); // 非常重要
if (isOnLine) { // 在线打开方式
URL u = new URL("file:///" + filePath);
response.setContentType(u.openConnection().getContentType());
response.setHeader("Content-Disposition", "inline; filename="
+ f.getName());
// 文件名应该编码成UTF-8
} else { // 纯下载方式
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition",
"attachment; filename=" + f.getName());
}
OutputStream out = response.getOutputStream();
while ((len = br.read(buf)) > 0)
out.write(buf, 0, len);
br.close();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
*/
public HttpServletRequest getRequest() {
ActionContext ac = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest) ac
.get(ServletActionContext.HTTP_REQUEST);
return request;
}
/**
* 获取response 方法
*
* @return HttpServletResponse
*/
public HttpServletResponse getResponse() {
ActionContext ac = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse) ac
.get(ServletActionContext.HTTP_RESPONSE);
return response;
}
4.8分页属性封装类
/**
* 分页属性封装类
* @author
* @category
*/
public class Page {
/** 翻页用的常量 */
public static final int baseNum = 10;
public static final int pageSize = WebConst.PAGESIZE;
/** 是否有上一页 */
private boolean hasPrePage;
/** 是否有下一页 */
private boolean hasNextPage;
/** 分页大小 */
private int everyPage;
/** 总页数 */
private int totalPage;
/** 当前页 */
private int currentPage;
/** 记录起始数 */
private int beginIndex;
/** 下一页 */
private int nextPage;
/** 上一页 */
private int previousPage;
/** 总记录数 */
private int totalCount;
/** 基于数字显示的数组 */
private String[] displayNum;
/** 跳转到下一个显示的数组 */
private int nextDisplayNum;
/** 跳转到上一个显示的数组 */
private int previousDisplayNum;
/** 是否有向前跳转图标 */
private boolean hasPreviousDisplayNum;
/** 是否有向后跳转图标 */
private boolean hasnextDisplayNum;
public int getNextDisplayNum() {
return nextDisplayNum;
}
public void setNextDisplayNum(int nextDisplayNum) {
this.nextDisplayNum = nextDisplayNum;
}
public String[] getDisplayNum() {
return displayNum;
}
public void setDisplayNum(String[] displayNum) {
this.displayNum = displayNum;
}
/**
* 默认的构造函数
*
*/
public Page() {
}
/**
* 用分页大小构造分页对象
*
* @param everyPage
* 分页大小
*/
public Page(int everyPage) {
this.everyPage = everyPage;
}
/**
* 完整的构造分页对象的方法
*
* @param hasPrePage
* 是否有上页
* @param hasNextPage是否有下页
* @param everyPage
* 分页大小
* @param totalPage
* 总页数
* @param currentPage
* 当前页
* @param beginIndex
* 记录起始数
* @param previousPage
* 上页页数
* @param nextPage
* 下页页数
* @param totalCount
* 总记录数
*/
public Page(boolean hasPrePage, boolean hasNextPage, int everyPage,
int totalPage, int currentPage, int beginIndex, int previousPage,
int nextPage, int totalCount, String[] displayNum,
int nextDisplayNum, int previousDisplayNum,
boolean hasPreviousDisplayNum, boolean hasnextDisplayNum) {
this.totalCount = totalCount;
this.hasPrePage = hasPrePage;
this.hasNextPage = hasNextPage;
this.everyPage = everyPage;
this.totalPage = totalPage;
this.currentPage = currentPage;
this.beginIndex = beginIndex;
this.previousPage = previousPage;
this.nextPage = nextPage;
this.displayNum = displayNum;
this.nextDisplayNum = nextDisplayNum;
this.previousDisplayNum = previousDisplayNum;
this.hasPreviousDisplayNum = hasPreviousDisplayNum;
this.hasnextDisplayNum = hasnextDisplayNum;
}
/**
* @return 记录起始数.
*/
public int getBeginIndex() {
return beginIndex;
}
/**
* @param beginIndex
* 设置记录起始位置.
*/
public void setBeginIndex(int beginIndex) {
this.beginIndex = beginIndex;
}
/**
* @return 当前页数.
*/
public int getCurrentPage() {
return currentPage;
}
/**
* @param currentPage
* 设置当前页页数.
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
/**
* @return 分页大小,即每页显示多少条记录.
*/
public int getEveryPage() {
return everyPage;
}
/**
* @param everyPage
* 设置分页大小.
*/
public void setEveryPage(int everyPage) {
this.everyPage = everyPage;
}
/**
* @return 是否有下页.
*/
public boolean getHasNextPage() {
return hasNextPage;
}
/**
* @param hasNextPage
* 设置是否有下页.
*/
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
/**
* @return 是否有上页.
*/
public boolean getHasPrePage() {
return hasPrePage;
}
首页
上一页
1
2
3
4
下一页
尾页
3
/4/4
相关论文
上一篇
:
项目管理系统设计与开发
下一篇
:
社区居民管理系统的设计与开发
推荐论文
本专业最新论文
Tags:
施工
监察
系统
设计
开发
【
返回顶部
】
相关栏目
自动化相关
计算机论文
工程管理论文
法律论文
医学论文
人力资源
电子专业
电气工程
英语论文
行政管理
电子商务
社科文学
教育论文
物流专业
金融专业
财务管理
会计专业
化学化工材料科学
电子通信
环境科学
经济类
机械模具类
报告,总结,申请书
其他专业论文