SpringMVC数据绑定四(自定义的类型转换器)
2024-10-21 14:21:50
1、PropertyEditor
继承PropertyEditorSupport
//controller
@Controller
public class TestController extends PropertyEditorSupport{
//重写PropertyEditorSupport的setAsText方法
@Override
public void setAsText(String text) throws IllegalArgumentException {
User u = new User();
String[] textArray = text.split(",");
u.setName(textArray[0]);
u.setAge(Integer.parseInt(textArray[1]));
this.setValue(u);
}
//TODO: http://127.0.0.1:8080/SpringMVC/propertyEditir?text=Tom,20
@RequestMapping(value="propertyEditir")
@ResponseBody
public String propertyEditir(String text) {
this.setAsText(text);
return ((User)this.getValue()).toString();
} }
2、Formatter
最新文章
- VC++常用函数
- 添加事件及Event对象的兼容写法
- NSDICTIONARY获取内容的CRASH
- 数据库的Instance/Crash Recovery
- JavaEE EL的一些用法
- Python中的基本语句
- 简易promise
- 服务列表 - Sina App Engine
- Linux 安装qt5-designer并集成到Pycharm
- 用Nuget部署程序包
- Select查询命令
- Excel 导出通用类
- ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: Cannot run program ";hive";: error=2, No such file or directory
- pkg-config原理及用法
- [作业] Python入门基础--三级菜单
- 一文看尽HashMap
- quick cocos2dx 3.x 配置win32工程
- 修改JQM的默认配置属性
- rocketmq消费负载均衡--push消费为例
- 使用FormData实现ajax文件异步上传
热门文章
- Codeforces Round #297 (Div. 2) [ 折半 + 三进制状压 + map ]
- D. Babaei and Birthday Cake---cf629D(最长上升子序列和+线段树优化)
- CD-----UVa624(01背包+输出路径)
- 转: ORACLE存储过程笔记3----流程控制
- git获取远程分支
- SQL Server Fundamentals
- 查看linux接口进出口流量的命令;linux 网络监控;流量监控
- [Node.js] Write or Append to a File in Node.js with fs.writeFile and fs.writeFileSync
- [TypeScript] Query Properties with keyof and Lookup Types in TypeScript
- Angular结构简单介绍