ASP.NET个人博客系统的设计与实现|个人网站
摘要
基于Microsoft.Net环境的ASP.NET技术,为开发功能强大的动态网站提供了一种简单、高效的途径。该博客系统以ASP.NET为开发技术,使用C#为开发语言,实现了博客网站的动态管理,使得对博客信息的管理更加及时、高效,提高了工作效率。同时对系统的背景需求、系统的功能特点和设计方案进行了介绍。该文还以随笔管理为例,对ASP.NET环境下的MVC开发模式进行了简单的介绍。.
关键字:ASP.NET;ADO.NET;博客;系统;数据库
ABSTRACT
Based on Microsoft.Net frame, The ASP.NET provides a simple, efficient way to develop a dynamic web site . The blog system takes ASP.NET as the development technology, uses C # as the development language, has realized the blog website dynamic management, caused to the blog information management even more prompt, to be highly effective, enhanced the working efficiency. Meanwhile , They take an introduction on the system background demand, the system function characteristic and the design project.This article also introduces the MVC pattern under ASP.NET environment by taking an example for the users’ management.
Keywords :ASP.NET;ADO.NET,;Blog;System;DataBase
“博客”一词是从英文单词Blog翻译而来。Blog是Weblog的简称,而Weblog则是由Web和Log两个英文单词组合而成。Weblog就是在网络上发布和阅读的流水记录,通常称为“网络日志”,简称为“网志”。它是继Email、BBS、IM之后出现的第四种全新的网络交流方式。它绝不仅仅是一种单向的发布系统,而且有着极其出色的交流功能。另外Blog也提供了非常方便实用的个性化功能。简言之,Blog就是以网络作为载体,简易迅速便捷地发布自己的心得,及时有效轻松地与他人进行交流,再集丰富多彩的个性化展示于一体的综合性平台。
如果说文化是一种生活状态,那么博客文化就是网上最平凡的生活状态之一。也正是这种平凡,才使得博客具有亲和力。加入博客几乎是“零门槛”,并不需要什么特殊技能。以文字为主的博客甚至抛开了视频、声音、图片等表现形式,它以文字最质朴的方式表达人们对生活的态度。只需要一台电脑、一个键盘和思想,你就可以成为博客的一员。网络从第一波的商业化,到后来的收费短信,承载了太多的商业化诉求。也许人们面对越来越华丽的网站制作感到了厌倦,反而觉得质朴的博客最能反映自己的思想,感受网络的平等和自由。
在网络这个大林子里,大鸟、菜鸟、或群居、或四处漂流,各自生存、互不干涉。早些时候,博客也不过是其中普通一种鸟罢了,并无特别之处。但不经意间,博客竟如雨后春笋般冒出来,博得了越来越多网民的欢心,并引发了各种新的应用热潮。它最大的吸引力在于,只要你会发邮件,就可以轻松创建自己的网络媒体。
一般一个博客就是一个页面,它通常由简单而且更新的帖子构成,所有文章都是按照年份和日期排列,有些类似斑竹的日记。看上去平淡无奇,毫无可炫耀之处,但它可以让每个人零成本 、零维护地创建自己的网络媒体,每个人都可以随时把自己的思想火花和灵感更新到博客站点上。
博客的人性化和平民视角使得它提供的消息更贴近人们的生活,而且他们搜集到的新闻资料大多是第一手资料。伊拉克战争就使得上百个个人博客网站成为传统站点消息的来源。
博客的操作方式非常简单,点点鼠标 、敲敲键盘 、随笔 、合影 、链接片刻之间就会出现在博客站点之上。
建立一个博客就是那么简单,有个博客系统的初体验,你还犹豫吗?建立自己的博客吧。在本论文中,我将创建一个自己的个人博客系统,来展示它。
本文通过实现个人博客系统,来对一个完整的博客系统项目进行分析和实现并且针对性的进行测试。下面是各个章节的概要介绍。
第1章的是博客项目的背景及相关描述。
第2章 将向你讲述博客系统的调研过程,和你一起探讨任何进行客户会谈,如何抽取系统的功能,如何进行需求的描述。
第3章 将向你展示实用UML进行系统分析和设计的过程,特别是如何进行系统的健壮性分析,是本论文的重点。
第4章 实现博客系统,分析如何进行代码规范 、检查和单元测试。另外,还将实现文件上传、验证码的生成、图像的缩略生成等功能的实现,这样可以轻而易举地将它们移植到系统中。
第5章 介绍交互测试的方法 、性能测试的方法和Application Test Center工具
第6章 总结项目
2.1 ASP.NET 概述
ASP.NET是把基于通用语言的程序在服务器上运行。不像以前在ASP即时解释程序,而是程序在服务器端首次运行时进行编译,这样的执行效果,当然逐条解释的效率很多。
ASP.NET构架可以用MICROSOFT公司最新产品 VISUAL STUDIO.NET开发环境进行开发,具有WYSIWYG的编译功能,而这仅是ASP.NET强大软件支持的一小部分。
因为ASP.NET是基于用用语言的编译运行程序,所以它的强大性和适应性,可以使它运行在WEB应用软件开发者的几乎全部平台上。通用语言的基本库、消息机制、数据接口的处理都能无缝地整合到ASP.NET的WEB应用中。ASP.NET同时也是LANGUAGE-INDEPENDENT语言独立化的,所以,你可以选择一种最适合你自己语言的语言来编写你的程序,或者吧你的程序用很多种语言来写,现在已经支持的有c#、VB、DELPHI等。将来,这样的多种程序语言协同工作的能力保护你现在的基于COM+开发的程序,能够完整地移植向ASP.NET。
ASP.NET使运行一些很平常的任务变得非常简单。例如,ASP.NET页面构架允许用户建立自己的用户界面,使其不同于常见的界面。
ASP.NET使用一种字符基础、分级的配置系统,使用户的服务器环境和应用程序的设置更加简单。因为配置信息都保存在简单文本中,新的设置有可能不需要启动本地的管理员工具就可以实现。这种被称为零本地管理的观念使ASP.NET的基于应用的开发更加具体和快捷。一个ASP.NET的应用程序在一台服务器系统的安装只需要简单的拷贝一些必须文件,不需要系统的重新启动,一切就是这么简单。
ASP.NET已经被刻意设计称为一种可以用于多处理器的开发工具,它在多处理器的环境下用特殊的无缝链接技术,将大大地提高运行速度。即使你现在的ASP.NET应用软件是为一个处理器开发的,将来多处理器运行时不需要任何改变都能提高它们的效能,但现在的ASP都做不到这一点。
ASP.NET设计时考虑了让网站开发人员可以在自己的代码中定义”PLUG-IN“的模块。这与原来的包含关系不同,ASP.NET可以加入自己定义的任何组件。网站程序的开发从来没有这么简单过。
基于WINDOWS认证技术和应用程序配置,你可以确信你的源程序是绝对安全的。
2.2 第一个ASP,NET程序
ASP.NET提出一个概念,就是认为WEB页面也是一个窗体,所以,使用过DELPHI、VB等开发工具的朋友,学起来相对简单多了。
ASP.NET页面的后缀名是:.aspx,所以IIS在安装完.NET FRAMEWORK时,也会把DEFAULT.ASPX作为你的默认首页,网管朋友一定要注意了。ASP.NET是编译运行的,只是在第一次运行时编译,所以,以后的运行速度比ASP执行快。
2.3 ASP.NET基础知识
在ASP中有Application、Cookie、Session、Cookie等内置对象,在ASP.NET中,它们也受到了足够的重视,但与ASP相比变化不是很大。
Application
在ASP.Net 中Application用法与ASP是一样的,几乎是没有什么说的,但是它多了两个特别有用的事件, Application_OnBeginRequest和Application_OnEndRequest。他们的和原来的 Application_OnStart和Application_OnEnd一样是放在global文件中的(注意这个文件在ASP中名字是 global.asa,在ASP.Net中是global.asax)。
注:这个事件,写不写On是一样的。如Application_End与Application_OnEnd是一样的
Application_OnStart是在整个ASP.Net应用首先被触发的事件,也就是在一个虚拟目录中第一个ASP.Net程序执行时 触发,Application_OnEnd就正好相反,在整个应用停止时被触发(通常发生在服务器被重启/关机时)。 Application_OnRequestStart和Application_OnRequestEnd则是在每一个ASP.Net程序被请求时就发 生,也就是说客户访问一次一个ASP.Net程序,这两个事件就会被触发。我们可以从下面的程序看到他的应用.我们先建立一个global.asax,内 容。然后将其放到本虚拟目录的根目录下,然后我们随便打开一个什么aspx文件我们在global.asax中定义的语句Request is Starting...和Request is Ending...这个不是我们在这个文件中独加的,我们将会再任何一个ASP.Net文件中看到它的影子。
根据Blog要以网络作为载体,简易迅速便捷地发布自己的心得,及时有效轻松地与他人进行交流,再集丰富多彩的个性化展示于一体的综合性平台的需求前景,从软件工程的角度来实现该系统,先研究分析了市场的需求前景,后进行需求分析,之后代码实现,最后测试和安装调试。本文通过实现个人博客系统,来对一个完整的博客系统项目进行分析和实现并且针对性的进行测试。系统虽然简单,但是完全按照软件工程流程进行设计和开发,设计严谨合理,界面简洁,用户操作方便。
本系统采用MS ASP.NET2.0开发环境,MS SQL Server2000数据库。部署在Windows 操作系统IIS服务器上。
[1] ASP.NET高级编程 清华大学出版社
[2] ASP.NET从入门到精通 人民邮电出版社
[3] 程序员大本营.Net版(CHM)
[4] Madeleine
[5] 用XML轻松开发WEB站点
[6] asp.net宝典
[7] C#.NET 开发者手册
[8] Kenneth J Klassen, Thomas R Rohleder, Combining operations and marketing to manage capacity and demand in services, The Service Industries Journal, 2001, Vol.21,No.2:25~30
[9] Rhyne, David M, the Impact of Demand Management on Service System Performa, the Service Industries Journal, 1988, Vol.8,No.4:26~31
[10] Douglas R Moodie,Demand management: The evaluation of price and due date negotiation strategies using simulation,Production and Operations Management, 1999, Vol.8, No.2:15~23
[11] Eitan Altman, Uri Yechiali, Analysis of customers' impatience in queues with server vacations,Queuing Systems, 2006, Vol.52,No.4:61~63
[12] MySQL开发者SQL权威指南
[13] SQL Server 程序设计
[14] Ward Whitt, Sensitivity of Performance in the Erlang-A Queuing Model to Changes in the Model Parameters, Operations Research, 2006, Vol.54,No.2:14~18
致 谢
本文是在
此外还要感谢辛勤培育我的老师们,及朝夕相处的同学们,他们的关心使我充满动力,他们在系统设计初期给予的帮助,使此系统的开发,有了一个很好的开端!感谢同学们在专业知识上给予我的帮助,因为他们的协助,才得以顺利完成了设计!
在论文完成过程中,本人还得到了其他老师和许多同学的热心帮助,本人向他们表示深深的谢意!
最后向在百忙之中评审本文的各位专家、老师表示衷心的感谢!
Web MVC with the Spring Framework
Juergen Hoeller
1. Introduction: Spring the Application Framework
When first confronted with the Spring Framework, one might be tempted to think: "Oh no, not yet another web framework". This article will outline why Spring isn't particularly a web framework but a generic lightweight application framework with dedicated web support, and show the architectural differences to Struts and WebWork
In contrast to Struts or WebWork, Spring is an application framework for all layers: It offers a bean configuration foundation, AOP support, a JDBC abstraction framework, abstract transaction support, etc. It is a very non-intrusive effort: Your application classes do not need to depend on any Spring classes if not necessary, and you can reuse every part on its own if you like to. From its very design, the framework encourages clean separation of tiers, most importantly web tier and business logic: e.g. the validation framework does not depend on web controllers. Major goals are reusability and testability: Unnecessary container or framework dependencies can be considered avoidable evils.
Of course, Spring's own web support is nicely integrated with the framework's general patterns. Nevertheless, replacing the web solution with Struts, WebWork, or the like is easy. Both with Spring's web support or a different one, Spring allows for building a true dedicated middle tier in the web container, with the option to reuse exactly the same business logic in test environments or standalone applications. And within J2EE, your business logic will not unnecessarily depend on container services like JTA or EJB - allowing complex, well-architected web applications to run in a "simple" container like Tomcat or Resin.
Note that Spring doesn't generally aim to compete with existing solutions. It rather fosters seamless integration with standards like Servlet, JSP, JTA, JNDI, JDBC, and JDO, and well-suited tools like Hibernate, Velocity, Log4J, and Caucho's Hessian/Burlap. The framework is designed to grow with the needs of your applications, in terms of technology choice: For example, you will probably use JTA via Spring's JtaTransactionManager if you need distributed transactions - but only then, as there are perfect replacements for single databases, like DataSourceTransactionManager or HibernateTransactionManager.
2. Web MVC: The Design of Spring's Web Framework
Spring's web framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, and locale and theme resolution. The default handler is a very simple Controller interface, just offering a "ModelAndView handleRequest(request,response)" method. This can already be used for application controllers, but you will prefer the included implementation hierarchy, consisting of AbstractController, AbstractCommandController, MultiActionController, SimpleFormController, AbstractWizardFormController. Application controllers will typically be subclasses of those. Note that you can choose an appropriate base class: If you don't have a form, you don't need a FormController. This is a major difference to Struts.
You can take any object as command or form object: There's no need to implement an interface or derive from a base class. Spring's data binding is highly flexible, e.g. it treats type mismatches as validation errors that can be evaluated by the application, not as system errors. So you don't need to duplicate your business objects' properties as Strings in your form objects, just to be able to handle invalid submissions, or to convert the Strings properly. Instead, it's often preferable to bind directly to your business objects. This is another major difference to Struts which is built around required base classes like Action and ActionForm - for every type of action. Compared to WebWork, Spring has more differentiated object roles: It supports the notion of a Controller, an optional command or form object, and a model that gets passed to the view. The model will normally include the command or form object but also arbitrary reference data. Instead, a WebWork Action combines all those roles into one single object. WebWork does allow you to use existing business objects as part of your form, but just by making them bean properties of the respective Action class. Finally, the same Action instance that handles the request gets used for evaluation and form population in the view. Thus, reference data needs to be modelled as bean properties of the Action too. These are arguably too many roles in one object.
Regarding views: Spring's view resolution is extremely flexible. A Controller implementation can even write a view directly to the response, returning null as ModelAndView. In the normal case, a ModelAndView instance consists of a view name and a model Map, containing bean names and corresponding objects (like a command or form, reference data, etc). View name resolution is highly configurable, either via bean names, via a properties file, or via your own ViewResolver implementation. The abstract model Map allows for complete abstraction of the view technology, without any hassle: Be it JSP, Velocity, or anything else - every renderer can be integrated directly. The model Map simply gets transformed into an appropriate format, like JSP request attributes or a Velocity template model.
3. Integration: Using a Different Web Framework with Spring
Many teams will try to leverage their investments in terms of know-how and tools, both for existing projects and for new ones. Concretely, there are not only a large number of books and tools for Struts but also a lot of developers that have experience with it. Thus, if you can live with Struts' architectural flaws, it can still be a viable choice for the web layer. The same applies to WebWork and other web frameworks.
If you don't want to use Spring's web MVC but intend to leverage other solutions that Spring offers, you can integrate the web framework of your choice with Spring easily. Simply start up a Spring root application context via its ContextLoaderListener, and access it via its ServletContext attribute (or Spring's respective helper method) from within a Struts or WebWork action. Note that there aren't any "plugins" involved, therefore no dedicated integration: From the view of the web layer, you'll simply use Spring as a library, with the root application context instance as entry point. All your registered beans and all of Spring's services can be at your fingertips even without Spring's web MVC. Spring doesn't compete with Struts or WebWork in this usage, it just addresses the many areas that the pure web frameworks don't, from bean configuration to data access and transaction handling. So you are able to enrich your application with a Spring middle tier and/or data access tier, even if you just want to use e.g. the transaction abstraction with JDBC or Hibernate.
4. Feature Check List
If just focussing on the web support, some of Spring's unique features are: .Clear separation of roles: controller vs validator vs command object vs form object vs model object, DispatcherServlet vs handler mapping vs view resolver, etc. .Powerful and straightforward configuration of both framework and application classes as JavaBeans, including easy in-between referencing via an application context, e.g. from web controllers to business objects and validators. .Adaptability, non-intrusiveness: Use whatever Controller subclass you need (plain, command, form, wizard, multi action, or a custom one) for a given scenario instead of deriving from Action/ActionForm for everything. .Reusable business code, no need for duplication: You can use existing business objects as command or form objects instead of mirroring them in special ActionForm subclasses. .Customizable binding and validation: type mismatches as application-level validation errors that keep the offending value, localized date and number binding, etc instead of String-only form objects with manual parsing and conversion to business objects. Customizable handler mapping, customizable view resolution: flexible model transfer via name/value Map, handler mapping and view resolution strategies from simple to sophisticated instead of one single way. Customizable locale and theme resolution, support for JSPs with and without Spring tag library, support for JSTL, support for Velocity without the need for extra bridges, etc. Simple but powerful tag library that avoids HTML generation at any cost, allowing for maximum flexibility in terms of markup code.
Spring的web MVC 构架模式
Juergen Hoeller
1. 介绍:Spring 应用构架
当你第一次看到Spring的时候,你一定会说:"哦不,又一种web 构架".这篇文章将告诉你Spring明显区别于其他轻量级application framework, 它将专注于web的支持,与struts 和 webwork有着明显的区别。
在和struts 和 webwork的对比上,Spring是一个服务于所有层面的application framework:提供了bean的配置基础,AOP的支持,JDBC的提取框架,抽象事务支持,等等。它有一个非常显著的特点:在某个层面上如果你不需要Spring的支持,你就可以不使用String的class,只使用它的某一部分的功能。 从它的设计理念,你可以看到String 帮助你实现了真正的逻辑层和web层的分离:例如。一个校验应用将不用依靠controllers,就可以实现。这样的目标是 更好的重用和易测:过分依靠不必要的容器和框架将不能实现这一点。
当然,Spring 的自己的web支持和通常框架模式的细致完整.然而,Spring替换struts,webwork或者其他的web方案非常的容易.对于Spring的web支持或者不同的地方,Spring 允许你在web容器里面建立一个中间层,在测试环境或者标准独立的应用里面来设置重用你的商务逻辑.还有在J2EE环境里面,你的商务逻辑不必依靠容器提供的服务,像JTA ,EJB的支持.良好的构架的web应用可以运行在任何容器上,如,Tomcat 或者 Resin. 值得注意的是,Spring 不是和已经存在的解决方案进行竞争. 我们鼓励结合标准的技术,如, Servlet, JSP, JTA, JNDI, JDBC, and JDO, 和非常匹配的工具,如,Hibernate, Velocity, Log4J, and Caucho's Hessian/Burlap.这个框架的的设计思想是在你的应用需要改良的时候,你将会做一些技术的选择:例如,如果你需要分布式事务处理,你可能需要用Spring的Jta TransactionManager 来实现JTA服务.或者,用DataSourceTransactionManager or HibernateTransactionManager 来实现美妙完美的单个数据库交换。
2. Web MVC:Spring web 框架的设计思想
Spring 框架通过配置操作mappings,展示resolution,本地化和模版集成围绕着分派请求操作的servlet - DispatcherServlet设计的.缺省的操作是一个非常简单的控制接口, 他只提供了ModelAndView handleRequest(request,response)方法.这将用于一个应用的控制,但是,如果你想包含多个层次的控制,AbstractController, AbstractCommandController, MultiActionController, SimpleFormController, AbstractWizardFormController 将帮助你完成.应用控制将代表那些子系统.注意,你可以选择一个适当的基类:如果你没有 web form,你就不必用FormController.这就是和Struts最大的不同. 你可以通过命令或者form对象来操作任何对象:这不需要接口工具或者一个基础类的驱动.Spring的数据邦定是非常的灵活的.举例来说,它描述了具有在应用范围内的校验错误的输入机制,但不是系统错误.所以在你的form对象里面你不必复制你的业务对象的string属性,只操作出错的子任务,或者适当地转换string.换句话说,它通常可以很好的直接邦定你的业务对象. 这也是和struts围绕请求基础类Action 和 ActionForm (每个action操作类型) 建立主要的不同之一. 对比WebWork,Sping更多的区别在于对象角色:Sping支持控制器的感念,一个操作命令或者form对象,和得到数据传递给视图的模式.这个模式通常包含命令和form对象,但有时也包含任意的参考数据.换句话说,一个WebWork Action联合所有这些角色到一个单独的对象.WebWork 允许你用已经存在的业务对象作为你 form 的一部分,但是只生成各自Action 的 bean 属性. 最后,操作请求的Action 实例在一个视图里面获得付值和form population. 然而,参考数据也需要作为Action 的属性被模拟. 一个类里面有太多的角色是值得讨论的. 关于视图:Spring的视图方案非常的灵活. 一个控制器执行可以通过response 返回ModelAndView对象null,就可以直接写到一个视图.在通常的状况下,一个ModelAndView实例结合了 一个view 和一个 model Map,包含了bean name 和 通讯对象(像命令或者form,参考数据等等). View名称是非常高端的的配置,不是通过bean name, 一个properties 文件就是通过你自己的ViewResolver.这个抽象的model Map 允许你在视图层面完成提取,没有任何的争辩:JSP,Velocity,或者其他,每一种都可以直接完整使用.这个model Map 还可以简单得得到适当的格式化数据的转换,像JSP 请求属性或者Velocity 模版模式.
3. 集成:用Spring一个不同web 框架
许多开发团队将为他们已有的项目或者新的项目已经获得的期限和工具进行投资.这里没有像Struts那样大量的图书和工具,但是同样我们有大量的拥有Spring开发技巧的开发人员.然而,如果你愿意生活在Struts的构架瑕疵中的话,他将是你在web层开发不错的选择.当然,其他应用也是一样. 如果你不想用Spring的 web MVC ,但是想借用Spring嫁接其他的解决方案,你可以非常简单地通过Spring 继承你自己的web 框架.你可以非常简单地通过ContextLoaderListener 启动一个Spring root application context, 并且,通过Struts 或者WebWork 的action 利用ServletContext 属性(或者Spring 的helper方法)存取它. 值得注意的是, 这里没有任何的 "plugins"被调用,因此没有专门的集成:来自web层的视图, 你可以简单的将Spring作为一个管理application context 实例入口点的类库. 所有你注册bean和Spring服务都可以在不需要Spring的web MVC的情况下都可以被你轻松掌握.Spring 不是和Struts ,WebWork这些应用进行竞争,它将作为一个纯web框架应用于 很多领域,因为它不需要配置数据存储和事务操作.所以,你可以利用Spring提供的中间层和数据存储层来丰富你的应用,甚至,你想用JDBC或者Hibernate进行事务抽象.
4.特点核对列表
如果聚焦于web 支持,Spring的一些显著特点是: 清楚地角色分离:controller , validator , command object , form object , model object,和 DispatcherServlet , handler mapping vs view resolver, 等等 强大而且直接的框架和作为JavaBeans的应用配置,包括简单的参照和应用内容,例如,从web控制器到业务对象和数据校验. 适应性,外挂:无论什么样的控制器你都需要得到代替Action/ActionForm所做的每件事情的方案(简单,命令,form,范例,多重action,或者定制一个) 重用业务逻辑代码,不需要复制:你可以用已经有的业务逻辑对象作为命令或则form对象代替反射特定的ActionForm子类. 可订制的邦定和数据校验:作为应用级的输入机制的错误校验,固定日期和数字邦定,例如,通过手动检查和转换业务对象来替换单个的string。 可订制的操作,可订制的视图方案:通过name/value Map灵活的模型传送,用一个简单的方法从简单到复杂操作映射和视图方案策略.
本地定制和主题方案:Spring没有taglib,完全支持于JSPs,JSTL,不需要额外的连接就可以支持Velocity,等等. 简单但是强大的tag library避免了HTML产生的混乱,最大限度的灵活扩展了标记代码.
以上内容只是毕业设计作品的部分资料介绍,如果了解更多详情请联系客服QQ:57510459
购买帮助>>