public class ConventerAction extends ActionSupport { private Zuobiao zuobiao;
public Zuobiao getZuobiao() { return zuobiao; }
public void setZuobiao(Zuobiao zuobiao) { this.zuobiao = zuobiao; }
@Override public String execute() throws Exception { // TODO Auto-generated method stub return SUCCESS; }
}
package com.vle.conventer;
import java.lang.reflect.Member;import java.util.Map;
import ognl.DefaultTypeConverter;
import org.vle.domain.Zuobiao;
public class ZuobiaoConventer extends DefaultTypeConverter {
@Override public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType) { // TODO Auto-generated method stub if(Zuobiao.class==toType){ String files[]=(String[])value; String para[]=files[0].split(","); Zuobiao z=new Zuobiao(); z.setX(Integer.parseInt(para[0])); z.setY(Integer.parseInt(para[1])); return z; } if(String.class==toType){ Zuobiao z=(Zuobiao)value; String s="[x="+z.getX()+",y="+z.getY()+"]"; return s; } return null; } 最后将自定义编辑类编写属性文件注册zuobiao=com.vle.conventer.ZuobiaoConventer }
Powered by: BlogJava Copyright © viery