基于ssh的个人信息博客网站的设计与实现--毕业设计内容摘要:

分类导航条主要通过访问 Action 来实现超链接。 登录进入博客后首页如 图 45 所示 : 图 45 个人主页 个人资料修改页面 如 图 46 所示 : 图 46 会员资料修改 登录后,用户可以查看日志及日志评论、删除日志、写日志、发表新日志时可以选择或添加日志类型,选择是否对外公开。 页面设计效果如图 4 4 49 所示 : 11 图 47 日志管理 图 48 发表日志 关键程序代码如下: public ActionForward doWriteEssay(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException { User loginedUser = (User) ().getAttribute( loginedUser)。 Essay essay = new Essay()。 ((title))。 ((contents))。 EssayType essayType = ((request .getParameter(typeId)))。 (essayType)。 (((selfish)))。 12 ((0))。 (new Date())。 (loginedUser)。 (essay)。 (?operate=toMyEssay)。 return null。 } 图 49 日志 页面 相册功能模块的实现 登录后,用户可以查看图片、删除图片、上传图片、上传图片时可以选择或创建新相册,选择是否对外公开。 页面设计效果如图 4 411 所示: 图 410 相册管理 13 图 411 上传图片 关键程序代码如下: public ActionForward doAddAlbum(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException { (GBK)。 PrintWriter printWriter = ()。 User loginedUser = (User) ().getAttribute( loginedUser)。 UploadForm myForm = (UploadForm) form。 FormFile myFile = ()。 long typeId = ()。 int selfish = ()。 AlbumType albumType = (typeId)。 if (myFile != null) { String type = ()。 if ((image/pjpeg) || (image/gif) || (image/jpg) || (image/png) || (image/bmp)) { try { if (().length 10 * 1024 * 1024) { (文件大小: 14 + ().length + byte)。 (文件大于 10M)。 printWriter .println(scriptalert(39。 上传文件大于 10M,上传失败39。 )。 (1)。 /script)。 return null。 } String dir = (true).getServletContext() .getRealPath(/upload)。 File file1 = new File(dir + / + ())。 File file2 = new File(file1 + / + ())。 if (!()) { ()。 } if (!()) { ()。 } FileOutputStream fos = new FileOutputStream(file2 + / + ())。 (())。 ()。 ()。 } catch (Exception e) { ()。 printWriter .println(scriptalert(39。 上 传 文 件 错 误 , 上 传 失 败39。 )。 (1)。 /script)。 return null。 } Album album = new Album()。 15 (albumType)。 (())。 (selfish)。 (loginedUser)。 (album)。 (?operate=toMyAlbum)。 return null。 } else { printWriter .println(scriptalert(39。 你上传文件类型不合法 ,上传失败39。 )。 (1)。 /script)。 return null。 } } return null。 } 文件功能模块的实现 登录后,用 户可以查看文件详细信息、删除文件、上传文件、下载文件、上传文件时可以添加文件描述。 页面设计效果如图 41 41 414 所示: 图 412 文件管理 16 图 413 文件上传 关键程序代码如下: public ActionForward doAddFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException { (GBK)。 PrintWriter printWriter = ()。 User loginedUser = (User) ().getAttribute( loginedUser)。 UploadForm myForm = (UploadForm) form。 FormFile myFile = ()。 String describle = ()。 FileType usefulTyle = null。 if (myFile != null) { String type = ()。 if ((audio/mpeg)) { usefulTyle = (FileType) (name, mp3).get(0)。 } if ((application/msword)) { usefulTyle = (FileType) (name, doc).get(0)。 } 17 if ((text/plain)) { usefulTyle = (FileType) (name, txt).get(0)。 } if ((application/octetstream)) { usefulTyle = (FileType) (name, rar).get(0)。 } if ((application/pdf)) { usefulTyle = (FileType) (name, pdf).get(0)。 } if (usefulTyle != null) { try { String dir = (true).getServletContext() .getRealPath(/upload)。 File file1 = new File(dir + / + ())。 File file2 = new File(file1 + / + ())。 if (!()) { ()。 } if (!()) { ()。 } FileOutputStream fos = new FileOutputStream(file2 + / + ())。 (())。 ()。 ()。 } catch (Exception e) { 18 ()。 printWriter .println(scriptalert(39。 上 传 文 件 错 误 , 上 传 失 败39。 )。 (1)。 /script)。 return null。 } file = new ()。 (())。 (usefulTyle)。 (describle)。 ((0))。 (new Date())。 (loginedUser)。 (file)。 (?operate=toMyFiles)。 return null。 } else { printWriter .println(scriptalert(39。 你上传文件类型不合法 ,上传失败39。 )。 (1)。 /script)。 return null。 } } return null。 } 19 图 414 文件下载 关键程序代码如下: public ActionForward download(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException { String id = (id)。 downFile = () (Long .parseLong(id))。 String path =。 PrintWriter out = null。 (GBK)。 User loginedUser = (User) ().getAttribute( loginedUser)。 User hostUser = null。 if (loginedUser == null) { hostUser = (User) ().getAttribute(hostUser)。 String enteredId = (String) ().getAttribute( entere。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。