SSM框架实现数据库存储图片及读取图片

SSMPython学习系统小程序 SSM框架下Python学习小程序的开发与应用 基于SSM框架的Python学习小程序设计与实现 随着互联网技术的飞速发展,线上学习平台逐渐成为人们获取知识的重要途径。Python作为一种广泛应用于数据分析、人工智能和软件开发的编程语言,其学习需求也在不断增长。为了满足用户随时随地学习Python的需求,开发一个基于SSM框架的Python学习小程序显得尤为重要。SSM框架结合了Spring、SpringMVC和MyBatis的强大功能,能够高效地实现前后端分离和数据交互,为用户提供流畅的学习体验。 阅读详情

需求说明

这个案例纯粹是研究用的,以备日后查看,实际中暂时还没接触过此类应用。
需求:在数据库中存储图片资源并且可以在页面中显示
实际工作中,像图片这类资源都是存储在资源服务器上的,很少会存在数据库中,主要是效率问题。但通过这个需求还是能够锻炼一个下ssm框架的使用技术。

项目实现

好,废话不多说了,我们开始准备工作,首先,我们要把SSM框架搭好,因为本次讲的不是框架的搭建,这里默认大家都没有问题。按照分层代码模式把控制层、业务层和数据访问层都搭建好,我们这里模拟一个提交用户信息的场景,那么用户信息中有一项添加头像内容,需要用户在填写完基本信息后上传一个张自己的靓照,所以我们在创建User实体类时要加入一个实例属性头像,那么它的数据类型应该选什么类型呢,很显然它要保存的是图片,最好的类型就是字节数组了。

数据库设计

java代码部分准备完后,接下来我们要准备相应的数据库了,表的设计要与实体类属性一一对应,这里就不细说了,因为都十分简单,如果想映射简单点,最好按照约定命名即下划线与驼峰的约定。在设计表中主要是存储图片的字段它的类型?这里说的是数据库中字段的类型,如果对数据库比较熟悉那么大家肯定会想到BLOB类型,没错,我们这里就要用这个类型,不过这里需要强调的是BLOB类型虽然是用来在数据库中存储大数据的,但它其实也不是多大的数据都能存储,它的存储空间只有64k这个大小是mysql5.7中的上限,其它数据库暂时没查过,有清楚的可以补上。那么如果你的图片上传限制在64k应该就没问题,那如果大于这个上限怎么办呢,其实mysql提供了一个更大的存储类型longBLOB类型,用了这个类型基本就可以放心使用了。

类型转换

这个才是这个案例的主要内容,我们首先准备一个前端用户信息页面,当然除了基本信息外还需要一个上传文件控件,这些都是前端的东西,这里也就不说了我前端很菜0_0!!

Spring MVC 图片的上传和下载 阅读详情

相关推荐

HFSS学习笔记——Vivaldi天线仿真(一)

Vivaldi 天线HFSS仿真,HFSS中指数曲线绘制及曲面绘制。

and_future的博客 1万+

SAP移动类型

SAP移动类型移动类型定义 移动类型定义

qq_20593197的博客 6209

WIFI中CSI的读取

学习目标: 目前正在做基于WIFI的无设备定位,准备使用信道状态信息(CSI),学习一下。 目前采集数据环境已经搭建好,准备研究信号的预处理。 学习内容: 1、 信号的读取——read_bf_file函数的研究 2、 3、 4、 1. read_bf_file详解: %READ_BF_FILE Reads in a file of beamforming feedback logs. % This version uses the *C* version of read_bfee, ...

sz3076799的博客 8894

从波士顿动力SpotMini拆解看四足机器人机械设计:关节布局与电机选型的5个关键决策点

本文深入解析波士顿动力SpotMini四足机器人的机械设计,聚焦关节布局与电机选型的5个关键决策点。通过拆解髋关节偏移距、膝关节传动链、电机热管理等核心设计,揭示商业级四足机器人的工程智慧,为工业巡检、物流机器人等应用提供实用参考。

postgres8guard的博客 896

获取抖音中x-secsdk-csrf-token的方法

获取抖音中x-secsdk-csrf-token的方法

sh_moranliunian的博客 2022

基于Dify实现对Excel的数据分析

在dify部署完成后,大家就可以基于此进行各种应用场景建设,目前dify支持聊天助手(包括对话工作流)、工作流、agent等模式的场景建设,我们在日常工作中经常会遇到各种各样的数据清洗、格式转换处理、数据统计成图等数据分析工作,本次主要基于对话工作流模式对Excel文件、csv文件进行解析处理,并进行成图等数据分析工作。主要用到的插件有LLM节点,文档提取器、参数提取器、自定义代码节点、echart插件等。实现解析Excel数据,经过上述不同节点的处理分析流程,最终实现数据统计图展示。

hhue2007的专栏 1万+

【Unity Shader】Special Effects(十二)Glow 外发光(UI)

Properties_GlowColor ("外发光颜色", Color) = (0, 0, 0, 1)_GlowIntensity("外发光强度", Range(0, 1)) = 1参数详解:_GlowColor:外发光颜色,指定外发光的显示颜色。_GlowIntensity:外发光强度,指定外发光的显示强度,0为不可见,1为最强强度。

神码编程 936

手把手教你用 Cursor 写一个完整的 Web 应用(含前后端 + 部署)

本文介绍如何利用Cursor AI工具从零开发一个完整的全栈待办事项Web应用。文章针对开发者常见痛点——无法独立完成项目闭环,提供了一套AI驱动的全栈开发范式。通过Vue3+Node.js+MySQL技术栈,全程由Cursor自动生成项目架构、前后端代码、数据库设计,并解决联调、部署等关键问题。重点展示了如何用AI完成:项目规划与架构设计、后端接口开发、前端页面实现、跨域联调、打包优化及云端部署全流程。该方法将传统需要3-5天的开发工作压缩至1小时内完成,产出规范可上线的项目,特别适合想突破"碎

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 639

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

深度学习工具包 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")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

上一篇: IIS7整合Tomcat8
下一篇: 数组中出现频数最多的值排在前面,如果频数相同,数值大的排前面
CH2JC
博客等级 码龄19年 5粉丝 13原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值