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的更多相关文章

  1. Struts1.x 中的 Validate 框架

    转载于http://www.blogjava.net/nokiaguy/archive/2009/02/12/254421.html 一.Validator框架的优势       Validator框 ...

  2. struts1拦截器

    Struts2已经发布一段时间了,这个版本较struts1.x版本有了很大变化,其中一个就是增加了拦截器功能.这是个非常有用的功能,可是struts1.x却没有.     其实,struts1.x可以 ...

  3. struts1老古董配置

    <!--Struts1 struts-config.xml Demo --><?xml version="1.0" encoding="UTF-8&qu ...

  4. struts1与struts2的区别

    Struts2其实并不是一个陌生的Web框架,Struts2是以Webwork的设计思想为核心,吸收了Struts1的优点,因此,可以认为Struts2是Struts1和Webwork结合的产物. 简 ...

  5. 层层递进Struts1(六)自定义转换器

    Struts提供的类型转换有限,如果我们强行使用没有的类型转换,则会出现错误,以Date类型为例: org.apache.catalina.core.StandardWrapperValve invo ...

  6. struts1,struts2,hibernate,spring的运行原理结构图

    一.struts1运行原理 1.初始化:struts框架的总控制器ActionServlet是一个Servlet,它在web.xml中配置成自动启动的Servlet,在启动时总控制器会读取配置文件(s ...

  7. struts1.3整合spring2.5(将spring委托给struts方式)

    前提是配置完struts1.3 导包 spring-2.5.6.jar //spring核心包 spring-webmvc-struts-2.5.5.jar //struts整合spring使用 lo ...

  8. J2EE学习篇之--Struts1详解

    今天来看一下Struts1的相关知识,其实Struts现在是出名的,每个Web开发者都会知道的,也是现在比较流行的框架,下面就来看一下我们为什么要用Struts框架呢? 摘要 1.建立在mvc这种好的 ...

  9. spring 整合 Struts1.X [转]

    这篇博客摘自[http://blog.csdn.net/chendc201/article/details/8464008], 其中也有一些是自己增加的部分 . 第一步, 需要为 Struts 装载 ...

随机推荐

  1. Effective C++笔记:构造/析构/赋值运算

    条款05:了解C++默默编写并调用哪些函数 默认构造函数.拷贝构造函数.拷贝赋值函数.析构函数构成了一个类的脊梁,只有良好的处理这些函数的定义才能保证类的设计良好性. 当我们没有人为的定义上面的几个函 ...

  2. Codeforces Round #313 (Div. 2) C. Gerald's Hexagon 数学

    C. Gerald's Hexagon Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/pr ...

  3. python logging用法

    import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filename)s[line:%(line ...

  4. helpDB

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Da ...

  5. Xamarin Android项目运行失败

    Xamarin Android项目运行失败 错误信息:Build Failed: MonoDroid does not support running the previous version.  P ...

  6. Eval有什么功能?

    它的功能是把对应的字符串解析成JS代码并运行.应该尽量避免使用eval,因为不安全,非常耗性能.解析成JS代码要耗能,执行时也要耗能.

  7. HDU 4511 (AC自动机+状态压缩DP)

    题目链接:  http://acm.hdu.edu.cn/showproblem.php?pid=4511 题目大意:从1走到N,中间可以选择性经过某些点,比如1->N,或1->2-> ...

  8. 【wikioi】1907 方格取数3(最大流+最大权闭合子图)

    http://www.wikioi.com/problem/1907/ 这题我一开始想到的是状压,看到n<=30果断放弃. 然后也想到了黑白染色,然后脑残了,没想到怎么连边. 很简单的一题 黑白 ...

  9. More about dubbo

    一.前言 dubbo 作为分布式服务框架支持丰富的配置和扩展方式,其中包括:通讯协议.并发控制.多版本服务.结果缓存.泛化引用\实现.回声测试.上下文信息.事件通知.路由规则(可用于实现读写分离)等多 ...

  10. shell运算