MVC开发模式详解

MVC、MVP、MVVM三种模式的介绍及区别(代码例子说明) 主要介绍几种架构模式,以及之间的区别 阅读详情

MVC设计模式详解

1.Model-View-Controller(模型-视图-控制器)

   MVC设计模式实际上强制性地将程序的输入、处理、和输出分开。

   Model-View-Controller实际上担当着不同的角色。

   Model:代表着业务数据和业务逻辑处理,(主要包括业务逻辑模块(web项目中的dao类)和数据模块(model类)和JavaBean相同,由Model提供视图的显示数据,同时一个Model可以为多个视图提供业务数据,因此Model也就提高应用程序的可重用性。

   View:代表视图,也就是与用户交互的界面,可以给用户显示业务逻辑数据,同时也可以 接收用户输入的数据。(在web项目中以jsp作为view)

注意:在视图中不对数据进行任何的业务逻辑处理。

   Controller:代表控制器,用来接收从视图输入的参数,同时调用对应的Model模型对数据进行业务逻辑处理,同时将处理好的数据传递到对应的视图来显示给用户。(在web项目中以Servlet作为控制器)

   MVC的处理顺序:首先是用户通过视图将参数输入提交到控制器,控制器调用对应的Model去处理,同时将处理好的数据输出到对应的视图显示给用户。

   代表性的MVC框架有:Struts、SpringMVC、Tapestry

2.最典型的MVC就是JSP + servlet + javabean的模式

我们就使用这种模式开发!

  疑惑:为什么要使用MVC设计模式?

      1)在MVC设计模式中,强制地把应用程序的输入、处理和输出分开,这样就降低了应用程序的耦合性,使得web开发中的每个组件得以分开,分别负责处理不同的事情,对后来的维护会变得更轻松,同时也可以使得开发人员分别专注于不同的开发,美工只专注于视图的开发,程序员只专注于业务逻辑的实现。

      2)程序的重用性高。 

3.MVC模式用户的请求流程


4.项目的分层开发

在实际的项目开发中,我们通常使用要做到“高内聚,低耦合”那么要做到这一点,就必须使用分层开发,结合MVC设计进行项目开发的时候我们通常会分为控制器层-Service层-Dao层,三层开发,层与层之间通过接口来连接。

分层开发的示例图解如下图:


用户在浏览器中方法JSP页面进行操作的时候整个web应用使用分层开发的内部流程分为8步:

1)用户通过浏览器访问jsp页面也就是view层,在jsp上的所有操作都直接请求控制层 Servlet来完成。

2)控制层获取view层提交过来的参数通过JavaBean对象封装参数,然后将封装好的参数 传递到Model层中的Service中调用Service层进行数据的业务逻辑处理。

3)Service层将控制层传递过来的参数传递到Dao层,然后调用Dao层访问数据库。

4)Dao层根据Service层的参数需求来访问数据库。

5)数据库根据Dao层的操作将数据集返回Dao层。

6)Dao层将获得的数据通过JavaBean对象进行封装,然后将封装好的数据返回给Service 层。

7)Service层将Dao中返回的数据又返回给控制层。

8)控制层将得到的数据转发到对应的jsp页面给用户显示。

 

科研党福音:如何用Zotero+Paper Agent打造你的AI论文速递系统(附详细配置教程) 本文为科研工作者提供了一套利用Zotero和开源工具Paper Agent构建自动化AI论文速递系统的详细教程。该系统能基于用户在Zotero中的文献库智能学习研究兴趣,每日自动从arXiv等平台筛选、下载并深度解读最相关的前沿论文,生成个性化日报,实现从被动接收到主动精准获取的知识工作流重塑。 阅读详情

相关推荐

SpringBoot+Maven打包实战:把项目变成SDK供其他团队调用

本文详细介绍了如何将SpringBoot项目改造并打包成可被其他项目依赖的SDK。通过调整Maven配置,剥离SpringBoot父依赖与启动类,并定制打包插件,最终生成标准的JAR依赖库,实现从“可执行应用”到“组件化SDK”的优雅转变,便于团队间功能复用。

assembly8low的博客 827

MVC模式简介

MVC模式一.MVC是什么二.优缺点2.1 MVC模式的优点2.1.1 低耦合2.1.2 重用性高2.1.3 生命周期成本低2.1.4 部署快2.1.5 可维护性高2.1.6 有利软件工程化管理2.2 MVC模式的缺点2.2.1 没有明确的定义2.2.2 不适合小、中型应用程序2.2.3 增加系统结构和实现的复杂性2.2.4 视图对模型数据的低效率访问 一.MVC是什么 MVC 模式(Model–view–controller)是软件工程中的一种软件架构模式,它把软件系统分为三个基本部分:模型(Model)

weixin_45808737的博客 1万+

Abaqus 导出单元刚度矩阵和全局刚度矩阵

Abaqus 导出单元刚度矩阵和全局刚度矩阵

科技芯风 1万+

MVC模式

模型-视图-控制器(Model-View-Controller),简称为MVC。MVC已经成为软件设计者必须熟练使用的开发模式。本章必须理解、掌握在JSP程序设计中怎样具体体现MVC开发模式(其他语言的程序设计是非常类似的,仅仅是具体使用的API不同而已)。MVC是一种通过三部分构造一个软件或组件的理想办法。模型(model) 用于存储数据的对象。视图(view) 向控制器提交所需数据、显示模型中的数据。

weixin_62286238的博客 2363

SCU【C】程序设计基础期末安全项目lab2-Deadbeef-writeup(附题目&源码)

项目名称(本质:栈溢出攻击)【源码在文首】和lab1一样,此题又是美国卡耐基梅隆大学的平时作业哈哈哈! 项目要求是把栈溢出,强行更改函数返回值,输出0xdeadbeef。

2301_79586491的博客 1544

Intel MKL库常用模块的C语言实现

文章目录1. 随机数生成1.1 等概率的01分布 viRngUniform1.2 (复)高斯分布 vsRngGaussian2. 向量-向量运算2.1 向量数乘与加法 cblas_caxpby2.2 向量内积 cblas_cdotu_sub2.3 向量范数 cblas_scnrm23. 矩阵-向量运算3.1 矩阵存储方案3.2 矩阵-向量乘法 cblas_cgemv4. 矩阵-矩阵运算4.1 矩阵...

月半 月半的博客 4653

MVC模式实现用户信息列表展示案例

用户信息列表展示案例 1.需求:实现用户信息查询 效果: 1.设计:Servlet+JSP+My![在这里插入图片描述](https://img-blog.csdnimg.cn/2020121020485663.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTI4OTM3NA==,size_16,color_FFFFFF,t_

大哥的阔落 1674

基于Mask-RCNN网络的书架图书书脊分割和检测(含代码)

图书馆的书架上的图书书脊分割/检测对于图书书名等信息的识别具有重要意义,因此,该博客基于Mask-RCNN网络实现了图书书脊的分割和检测,有利于进一步利用ocr文字识别技术实现图书书名等信息的入库。如下图所示,为书架原始数据和分割/检测后的结果。(本文已训练模型,无需训练)

qq_44619530的博客 2025

Extjs MVC开发模式详解

Extjs MVC开发模式详解 在JS的开发过程中,大规模的JS脚本难以组织和维护,这一直是困扰前端开发人员的头等问题。Extjs为了解决这种问题,在Extjs 4.x版本中引入了MVC开发模式,开始将一个JS(Extjs)应用程序分割成Model-View-Controller三层,为JS应用程序的如何组织代码指明了方向,同时使得大规模JS代码变得更加易于重用和维护;这就是Ex

Andy_java_的博客 401

5、高级综合技术:从调度到优化的全面解析

本文深入解析了高级综合技术,涵盖从控制/数据流图构建、调度算法、分配绑定策略到编译器优化的全流程。通过案例分析和对比,探讨了不同优化策略对性能和资源利用的影响,并总结了关键要点及未来发展趋势,为高效利用FPGA实现数字设计提供了全面指导。

night的博客 119

使用 FastAPI 和 LangGraph 构建生产级智能体 AI 系统

这是一本关于使用 FastAPI 和 LangGraph 构建生产级智能体 AI 系统的详细书籍,全文约 10 万字。《Production-Grade Agentic AI System Design and Implementation: Building Agentic AI Systems Using FastAPI and LangGraph》随着人工智能(AI)技术的迅猛发展,智能体(Agent)作为能够自主感知、推理、决策和行动的实体,正逐渐成为构建复杂智能系统的核心。从个性化推荐、客户服务到

AI天才研究院 348

Unity3D MVC开发模式与开发流程详解

MVC(Model-View-Controller)是一种常用的软件架构模式。将MVC应用于Unity3D开发可以提高项目的可维护性和可扩展性,使代码更加清晰和易于理解。本文将详细介绍Unity3D中MVC开发模式的应用以及开发流程,并给出技术详解和代码实现。对惹,这里有一个游戏开发交流小组,希望大家可以点击进来一起交流一下开发经验呀!一、MVC开发模式的概念MVC是一种将应用程序分为三个核心部分的软件架构模式:Model(模型)、View(视图)和Controller(控制器)。

Thomas_YXQ的博客 1670

194、产线 Camera 校准与测试:终检测试项、规格线制定与量产数据监控

摘要: 文章通过"绿屏门"案例揭示了产线Camera校准测试中的关键问题,提出了系统性改进方案。在终检测试方面,建议增加多增益暗电流测试、混合光源色温测试和径向亮度梯度测试,覆盖用户真实场景。规格线制定强调用CPK替代固定百分比,区分硬软规格并建立动态调整机制。量产监控需关注参数趋势、边界模组分布,构建失效模式数据库。实践建议包括测试冗余设计、规格余量预留、自动化监控、供应商数据共享和人工抽检保留。文章指出Camera产线质量管控需形成"测试设计-规格优化-数据监控"闭环,以数据驱动决策避免客诉风险。

sundong_81的博客 192

JSP详解与MVC开发模式介绍

文章目录1、JSP的3大指令2、JSP的6个动作标签3、JSP的9个内置对象4、EL表达式5、JSTL介绍6、页面域对象7、MVC开发模式8、单元测试 1、JSP的3大指令 在上一期会话技术的学习中,我 详细介绍了JSP是如何出现以及它的本质,JSP本质是一个servlet,它的出现是为了简化响应页面的书写,这篇文章中我总结了JSP是如何简化书写页面的; 指令:配置JSP页面的属性或者导入一些额外的内容 格式: <%@ 指令名称 属性名="属性值" %> 分类: page:配置JSP页

weixin_45082647的博客 1598

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

MVC开发模式和三层架构模式详解

## MVC:开发模式         ※1.jsp演变历史            1.早期只有servlet,只能使用response输出标签数据,非常的麻烦     ...

Monster丶ZF的博客 6944

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 无线点餐项目启动
下一篇: 餐桌、菜系管理
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Seven的代码实验室

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值