SpringMVC学习系列(4) 之 数据绑定-1

讲解 SpringMVC 中数据绑定的实现方式 在 Spring MVC 中,数据绑定是一个重要的特性,它允许将请求参数自动绑定到控制器方法的参数上,以及将模型数据自动填充到视图中。总之,Spring MVC 中的数据绑定提供了一种方便、高效的方式来处理用户输入数据和模型数据的映射。数据绑定是将用户输入的数据(通常来自 HTTP 请求)与 Java 对象进行自动映射的过程。这样可以简化控制器方法中对请求参数的处理,以及在视图中展示模型数据的过程。JSON 数据的数据绑定。URL 参数的数据绑定。 阅读详情

SpringMVC学习系列(4) 之 数据绑定-1

http://www.cnblogs.com/liukemng/p/3729071.html

在系列(3)中我们介绍了请求是如何映射到一个action上的,下一步当然是如何获取到请求中的数据,这就引出了本篇所要讲的内容—数据绑定。

首先看一下都有哪些绑定数据的注解:

1.@RequestParam,绑定单个请求数据,可以是URL中的数据,表单提交的数据或上传的文件; 
2.@PathVariable,绑定URL模板变量值; 
3.@CookieValue,绑定Cookie数据; 
4.@RequestHeader,绑定请求头数据; 
5.@ModelAttribute,绑定数据到Model; 
6.@SessionAttributes,绑定数据到Session; 
7.@RequestBody,用来处理Content-Type不是application/x-www-form-urlencoded编码的内容,例如application/json, application/xml等; 
8.@RequestPart,绑定“multipart/data”数据,并可以根据数据类型进项对象转换;

下面我们来看如何使用:

1.@RequestParam:

为了验证文件绑定我们需要先做以下工作:

a.把commons-fileupload-1.3.1.jar和commons-io-2.4.jar两个jar包添加到我们项目。

b.配置我们项目中的springservlet-config.xml文件使之支持文件上传,内容如下:

==========================================================================================

SpringMVC学习系列(5) 之 数据绑定-2

在系列(4)中我们介绍了如何用@RequestParam来绑定数据,下面我们来看一下其它几个数据绑定注解的使用方法。

1.@PathVariable 用来绑定URL模板变量值,这个我们已经在系列(3)中介绍了使用方法,这里不在赘述。

2.@CookieValue 用来绑定Cookie中的数据。下面我们用获取Cookie中的sessionId做测试:

在DataBindController添加cookiebind action,代码如下:

http://www.cnblogs.com/liukemng/p/3736948.html
TortoiseSVN的安装与使用 TortoiseSVN的安装与应用1、安装1.1、下载TortoiseSVN    点击下载TortoiseSvn1.2、下载汉化包。上面的页面中,找到Chinese, simplified汉化包,点击32位或者64位的Setup,下载汉化包。1.3、安装TortoiseSVN。在选择安装路径页面时要记得勾选“command line client tools”,默认不是勾选的。这里不勾选的话在I... 阅读详情

相关推荐

Appsflyer Web2App实战指南:OneLink与Web SDK深度对比

本文深入对比了Appsflyer实现Web2App的两大核心工具:OneLink智能链接与Web SDK。OneLink提供开箱即用的智能跳转,部署快捷,适合快速推广;Web SDK则支持高度自定义的用户行为追踪,适合深度分析与精细化运营。文章提供了详细的配置指南、场景化选型建议及实战避坑技巧,帮助营销与开发团队根据自身需求选择最佳方案,有效提升从网页到应用的转化率与归因精度。

weixin_29213655的博客 459

SpringMVC 学习系列 (4) 之 数据绑定 -1

在系列(3)中我们介绍了请求是如何映射到一个action上的,下一步当然是如何获取到请求中的数据,这就引出了本篇所要讲的内容—数据绑定。 首先看一下都有哪些绑定数据的注解: 1.@RequestParam,绑定单个请求数据,可以是URL中的数据,表单提交的数据或上传的文件;  2.@PathVariable,绑定URL模板变量值;  3.@CookieValue,绑定Cookie数

小程序 1万+

从零构建智慧农业监测终端:STM32数据采集与LoRa组网实战

本文详细介绍了如何从零构建智慧农业监测终端,涵盖STM32数据采集与LoRa组网实战。通过DHT22温湿度传感器和YL-69土壤湿度传感器实现精准环境监测,结合LoRa无线传输技术解决偏远农田信号问题。文章还分享了硬件选型、电路设计、低功耗优化及Flutter跨平台应用开发等关键技巧,助力农业智能化升级。

weixin_29172963的博客 357

【Spring篇】SpringMVC的常见数据绑定

🧸安清h:个人主页 🎥个人专栏:【计算机网络】【Mybatis篇】【Spring篇】🚦作者简介:一个有趣爱睡觉的intp,期待和更多人分享自己所学知识的真诚大学生。 目录 🎯SpringMVC的简单数据绑定🚦创建Signon类🚦创建SignonDao接口🚦创建SignonDaoImp类🚦创建SignonService接口🚦创建SignonServiceImp类🚦创建web.xml文件🍔默认类型数据绑定✨创建控制器类LoginController✨创建登录页面login1.jsp🍔简

m0_74202856的博客 5653

【ESP32-IDF笔记】20-配置以太网网络(W5500)

基于ESP32IDF和官方的ethernet驱动,配置W5500以太网驱动芯片,实现ESP32的有线网络

别看了,就这些信息 3474

STM32G0实战:手把手教你用国产GD25Q16 Flash存储传感器数据(附完整驱动)

本文详细介绍了如何使用国产GD25Q16 Flash芯片与STM32G0系列MCU实现传感器数据存储的完整方案。从SPI接口配置、驱动层实现到存储系统架构设计,提供了实战代码和优化策略,帮助开发者快速构建高性价比的物联网数据存储系统。

weixin_30733003的博客 107

SpringMVC数据绑定

这表明getProducts()方法获取到了客户端请求中的参数proIds的值,并将请求参数中多个同名的proIds参数值全部存储在了getProducts()方法的proIds形参中,实现了集合的数据绑定。从图中所示的打印信息可以看出,程序打印出了提交的商品,这表明getProducts()方法获取到了客户端请求中的参数proIds的值,并将请求参数中多个同名的proIds参数值全部存储在了getProducts()方法的proIds形参中,实现了数组的数据绑定。

z_y_j229970438的博客 1565

从零搭建一个AF架构项目:基于TIA Portal V19和S7-PLCSIM的仿真调试全流程

本文详细介绍了如何在TIA Portal V19环境中从零搭建西门子Automation Framework(AF架构)项目,包括环境准备、硬件组态、核心组件创建、项目架构分层实现以及仿真调试全流程。通过模块化编程和标准化接口设计,AF架构显著提升工业自动化项目的开发效率和维护便利性,特别适合S7-1500系列PLC的应用开发。

weixin_29313547的博客 676

SpringMVC系列--数据绑定

数据绑定概述 在执行程序时,SpringMVC根据客户端请求参数的不同将请求消息中的消息以一定的方式转换并绑定到控制器类的方法参数中。 在数据绑定过程中,SpringMVC会通过数据绑定组件(DataBinder)将请求参数串的内容进行类型转换,然后将转换后的值赋给控制器类中方法的形参。具体处理步骤如下: Spring MVC将ServletRequest对象传递给DataBinder 将处理方法的入参对象传递给DataBinder DataBinder调用ConversionService组件进行数据类

qq_43404873的博客 1002

基于STM32的智能衣柜系统开发实战(附完整源码与硬件设计)

本文详细介绍了基于STM32的智能衣柜系统开发实战,包括硬件设计、软件架构和云端功能实现。系统具备实时温湿度监控、自动加热除湿、紫外线杀菌等核心功能,通过STM32F103C8T6主控芯片和ESP8266无线模块实现智能控制。附完整源码与硬件设计,适合科技爱好者和开发者参考。

peach的博客 782

先进封装Interposer仿真步骤及说明

摘要: Interposer仿真是2.5D/3DIC封装设计的关键环节,涵盖信号完整性(SI)、电源完整性(PI)、热及结构应力分析。流程分为五个阶段:1)前处理,定义层叠结构与材料属性;2)参数提取,通过3D电磁建模获取TSV、传输线等寄生参数;3)仿真设置,选择求解器并设定频率范围;4)结果分析,评估信号损耗、阻抗及电源网络性能;5)后处理,进行多物理场协同仿真并生成模型。核心挑战在于多尺度与多物理场耦合,需优先确保高速信号与电源网络的仿真精度。常用工具包括Ansys HFSS、Cadence Sigr

DSY_0324的博客 1351

SpringMVC | SpringMVC中的 “数据绑定”

目录: “数据绑定” 介绍 1.简单数据绑定 : 绑定 “默认数据” 类型 绑定 “简单数据类型” 类型 (绑定Java“基本数据类型”) 绑定 “POJO类型” 绑定 “包装 POJO” “自定义数据” 绑定 : Converter (自定义转换器) .....

m0_70720417的博客 1661

Firefox卸载卡住不动的解决方案

本文主要介绍了Firefox卸载卡住不动的解决方案,希望能对使用Windows的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 15万+

SpringMVC学习(4):数据绑定1 @RequestParam

在系列(3)中我们介绍了请求是如何映射到一个action上的,下一步当然是如何获取到请求中的数据,这就引出了本篇所要讲的内容—数据绑定。 首先看一下都有哪些绑定数据的注解: 1.@RequestParam,绑定单个请求数据,可以是URL中的数据,表单提交的数据或上传的文件; 2.@PathVariable,绑定URL模板变量值; 3.@CookieValue,绑定Cookie数据; 4.@

乐在克里特的博客 360

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

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

SpringMVC常见组件之DataBinder数据绑定器分析

什么是数据绑定?简单一句话就是把请求中参数信息绑定到目标方法的参数上。数据绑定是参数解析过程中的一部分。如下图所示: 那么这里我们就要研究一下数据绑定相关的那些组件。 【1】绑定工厂WebDataBinderFactory 工厂嘛,使用了工厂方法设计模式,只有一个抽象方法用来让子类实现以创建一个WebDataBinder实例。 public interface WebDataBinderFactory { WebDataBinder createBinder(NativeWebRequest webRe

小小默:进无止境 3866

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

上一篇: 【Eclipse】推荐UML插件Green UML、AmaterasUML
下一篇: Tomcat中配置下载文件类型
lcathm
博客等级 码龄18年 37粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值