struts1 plugin
struts plugin 在struts.xml中注册之后,在系统启动之后调用 init 方法,通常在init方法中进行转化器的注册,在destory中移除转化器
1. struts文件
<plug-in className="com.test.util.DoubleConverterPlugIn"></plug-in>
2.插件类实现
public class DoubleConverterPlugIn implements PlugIn{
public DoubleConverterPlugIn() {
}
public void destroy() {
// 把注册移除
ConvertUtils.deregister();
}
public void init(ActionServlet arg0, ModuleConfig arg1)throws ServletException {
ConvertUtils.register(new DoubleConverter(), Double.class);
}
}
3. Double转化器的实现,此转化器在form bean中属性是double类型赋值时候自动调用
public class DoubleConverter implements Converter{
public Object convert(Class type, Object value) {
Double doubleValue = new Double(0);
if(value != null && !"".equals(value)){
if(value instanceof String){
String str = (String) value;
str = str.replaceAll(",", "");
try{
doubleValue = new Double(str);
}catch (Exception e) {
e.printStackTrace()
}
}
}
return doubleValue;
}
}
struts1 plugin的更多相关文章
- Struts1.x 中的 Validate 框架
转载于http://www.blogjava.net/nokiaguy/archive/2009/02/12/254421.html 一.Validator框架的优势 Validator框 ...
- struts1拦截器
Struts2已经发布一段时间了,这个版本较struts1.x版本有了很大变化,其中一个就是增加了拦截器功能.这是个非常有用的功能,可是struts1.x却没有. 其实,struts1.x可以 ...
- struts1老古董配置
<!--Struts1 struts-config.xml Demo --><?xml version="1.0" encoding="UTF-8&qu ...
- struts1与struts2的区别
Struts2其实并不是一个陌生的Web框架,Struts2是以Webwork的设计思想为核心,吸收了Struts1的优点,因此,可以认为Struts2是Struts1和Webwork结合的产物. 简 ...
- 层层递进Struts1(六)自定义转换器
Struts提供的类型转换有限,如果我们强行使用没有的类型转换,则会出现错误,以Date类型为例: org.apache.catalina.core.StandardWrapperValve invo ...
- struts1,struts2,hibernate,spring的运行原理结构图
一.struts1运行原理 1.初始化:struts框架的总控制器ActionServlet是一个Servlet,它在web.xml中配置成自动启动的Servlet,在启动时总控制器会读取配置文件(s ...
- struts1.3整合spring2.5(将spring委托给struts方式)
前提是配置完struts1.3 导包 spring-2.5.6.jar //spring核心包 spring-webmvc-struts-2.5.5.jar //struts整合spring使用 lo ...
- J2EE学习篇之--Struts1详解
今天来看一下Struts1的相关知识,其实Struts现在是出名的,每个Web开发者都会知道的,也是现在比较流行的框架,下面就来看一下我们为什么要用Struts框架呢? 摘要 1.建立在mvc这种好的 ...
- spring 整合 Struts1.X [转]
这篇博客摘自[http://blog.csdn.net/chendc201/article/details/8464008], 其中也有一些是自己增加的部分 . 第一步, 需要为 Struts 装载 ...
随机推荐
- Oracle 连接 Visual Studio 的工具
Oracle 连接 Visual Studio 的工具 ① ② ③
- 利用SQL语句查询数据库中所有表
Oracle: SELECT * FROM ALL_TABLES;系统里有权限的表 SELECT * FROM DBA_TABLES; 系统表 SELECT * FROM USER_TABLES; 当 ...
- Windows计数器做性能监控(window server 2008服务器)
使用Windows计数器 一.创建数据收集器集 二.创建数据收集器 三.使用数据收集器 1.修改数据收集器的属性 2.手动启用.手动停止数据收集器集 3.计划任务 4.在性能监视器中查看 一.性能监视 ...
- 模拟 Coder-Strike 2014 - Round 1 A. Poster
题目地址:http://codeforces.com/problemset/problem/412/A /* 模拟:题目没看懂,但操作很简单,从最近的一头(如果不在一端要先移动到一端)往另一头移动,顺 ...
- [leetCode][016] Add Two Numbers
[题目]: You are given two linked lists representing two non-negative numbers. The digits are stored in ...
- POJ 3335 Rotating Scoreboard(多边形的核)
题目链接 我看的这里:http://www.cnblogs.com/ka200812/archive/2012/01/20/2328316.html 然后整理一下当做模版.0换成eps,会wa,应该要 ...
- ARC指南2 - ARC的开启和禁止
要想将非ARC的代码转换为ARC的代码,大概有2种方式: 1.使用Xcode的自动转换工具 2.手动设置某些文件支持ARC 一.Xcode的自动转换工具 Xcode带了一个自动转换工具,可以将旧的源代 ...
- QCheckBox 的按钮响应
Qt中QCheckBox的按键响应如下,其中checkbox为对象名: void YourClass::on_checkbox_toggled(bool state) { // Do somethin ...
- php 类
<?php class mysql{ private $host; private $name; private $pass; private $table; private $ut; func ...
- Intent学习笔记
Intent首先字面意思大概是意图.负责activity之间或者,activity与service等(我只知道这么点)之间信息的传递.就跟快递员起的作用差不多(我这这么理解),由一下六部分组成: Co ...