《综合课程设计》报告(7)

2018-11-23 23:17

计算机科学与技术专业2011级《综合课程设计》报告

附录

部分程序源代码及注释说明

由于本系统是使用SSH框架做的,其中的配置文件说明了程序之间的调用关系,因此这些配置文件我们必须要了解和掌握。

(1) 部分spring配置文件

Spring作为一种轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。它包含并管理应用对象的配置和生命周期,配置每个bean的单独实例和它们的关联关系。

下面是数据库和hibernate的配置信息:

value=\>

class=\>

- 27 -

计算机科学与技术专业2011级《综合课程设计》报告

org.hibernate.dialect.SQLServerDialect true

com/model/TAdmin.hbm.xml com/model/TLiuyan.hbm.xml com/model/TUser.hbm.xml

com/model/TCatelog.hbm.xml com/model/TYinyue.hbm.xml

[3]

[11]

(2) 部分struts配置文件

struts通过采用JavaServlet和JSP技术,实现了基于Java EEWeb应用的MVC设计模式的应用框架,是MVC经典设计模式中的一个经典产品。struts配置文件的作用是将组件组合到一起。

配置全局转发和ActionMapping:全局转发用来在JSP页之间创建逻辑名称映射。转发都可以通过对调用操作映射的实例来获得。ActionMapping对象帮助进行框架内部的流程控制,它们可将请求URI映射到Action类,并且将Action类与ActionForm bean相关联。下面是部分实例:

/common/succeed.jsp

/common/add_success.jsp /common/del_success.jsp

name=\>/common/update_success.jsp

- 28 -

计算机科学与技术专业2011级《综合课程设计》报告

/upload/upload_re.jsp

/qiantai/index.jsp

(3)音乐上传代码

public class upload extends ActionSupport {

private static final int BUFFER_SIZE = 16 * 1024; private File fujian;

private String fujianFileName; private String fujianContentType; public String upload() { }

private static void copy(File src, File dst) {

InputStream in = null; OutputStream out = null; try {

in

=

new

BufferedInputStream(new

- 29 -

String newFujianName = new Date().getTime()

+ fujianFileName.substring(fujianFileName.indexOf(\\

+ \

String dstPath = ServletActionContext.getServletContext().getRealPath(

File dstFile = new File(dstPath); copy(this.getFujian(), dstFile);

Map request = (Map) ServletActionContext.getContext().get(\request.put(\request.put(\

request.put(\return ActionSupport.SUCCESS;

FileInputStream(src),

计算机科学与技术专业2011级《综合课程设计》报告

BUFFER_SIZE); }

}

}

out = new BufferedOutputStream(new FileOutputStream(dst),

BUFFER_SIZE);

byte[] buffer = new byte[BUFFER_SIZE]; int len = 0;

while ((len = in.read(buffer)) > 0) { }

e.printStackTrace(); if (null != in) { }

if (null != out) { }

try { }

out.close(); e.printStackTrace(); } catch (IOException e) { try { }

in.close();

e.printStackTrace(); } catch (IOException e) { out.write(buffer, 0, len);

} catch (Exception e) { } finally {

(4)分页显示代码

//封装页面显示逻辑 public class Pagination {

private int totle;// 总共的数据量

- 30 -

计算机科学与技术专业2011级《综合课程设计》报告

public String getPageDisplay() {

StringBuffer displayInfo = new StringBuffer(); if (index == 0 || pageSize == 0) { } else {

displayInfo.append(\); displayInfo.append(\共\ + totle

+ \条记录    每页

displayInfo.append(\没有分页的信息!\);

private int pageSize;// 每页显示多少条 private int totlePage;// 共有多少页 private int index;// 当前是第几页 private List data; // 数据 private String path;// 连接路径

style='color:#FF0000'>\ + pageSize

displayInfo.append(\第\ + index

    \);

// 判断如果当前是第一页 则“首页”和“第一页”失去链接 if (index == 1) { } else {

displayInfo.append(\ + path

+ \首页    \); + \上一页

- 31 -

displayInfo.append(\首页    \); displayInfo.append(\上一页    \);

displayInfo.append(\ + path + \ + (index - 1)

计算机科学与技术专业2011级《综合课程设计》报告

     \); }

}

}

return displayInfo.toString();

}

if (index >= this.getTotlePage()) { } else { }

displayInfo.append(\);

displayInfo.append(\ + path + \ + (index + 1)

+ \下一页    \); + this.getTotlePage() + \末页

displayInfo.append(\ + path + \

displayInfo.append(\下一页    \); displayInfo.append(\末页    \);

    \);

- 32 -


《综合课程设计》报告(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2018版高考英语浙江版二轮专题复习突破检测:专题三 完形填空模

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: