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 装载 ...
随机推荐
- 用c++处理文件流
#include<bits/stdc++.h> using namespace std; struct Bian { int num; string name; }b[]; int mai ...
- SU Demos-02Filtering-02Subfilt
巴特沃斯滤波器的特点是通频带的频率响应曲线最平滑.这种滤波器最先由英国工程师斯替芬·巴特沃斯(Stephen Butterworth)在1930年发表在英国<无线电工程>期刊的一篇论文中提 ...
- 贪心 URAL 1303 Minimal Coverage
题目传送门 /* 题意:最少需要多少条线段能覆盖[0, m]的长度 贪心:首先忽略被其他线段完全覆盖的线段,因为选取更长的更优 接着就是从p=0开始,以p点为标志,选取 (node[i].l < ...
- Sky数[HDU2097]
Sky数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- Codeforces Round #191 (Div. 2) E题
状态压缩DP,算sum,本来是枚举的,结果TLE了.. #include <iostream> #include <cstring> #include <cstdio&g ...
- Nhibernate Case SUM
SELECT ID END) as nbRowWithValueOf2, END) as nbRowWithValueOf3 FROM Foo GROUP BY ID queryover = quer ...
- iOS开发项目之一 [ 项目流程]
项目流程 *人员配置 *客户端(iOS工程师,Android工程师) *前端 h5 *后台人员(php,java,net) *提供接口(请求地址.请求参数,请求方式,接口文档) *UI UE * 效果 ...
- [转] - QPixmap全局变量载入多张图片失效问题
我想qt 中QPixmap这个类大家都很熟悉,它可以很简单的在标签上贴图:例如: QPixmap p; p.load("1.png"): label->setPixmap(p ...
- [百科] - iLBC
iLBC是一种专为包交换网络通信设计的编解码,优于目前流行的G.729.G.723.1,对丢包进行了特有处理,即使在丢包率相当高的网络环境下,仍可获得非常清晰的语音效果. 30ms ptime的iLB ...
- hdu How to Type
感觉这道dp题还是有点技巧的,此题设置了两个数组:open[]和close[],分别用来记录capslock一直开启状态和一直关闭状态下的最少输入次数.此时只要判断字母的大小写,选用最优子结构即可.状 ...