StringPEConverter.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:mocha-mvc 作者:
@Override
public Object convertOne(Class<?> type, InvokeContext ctx, Object from) {
    if (from != null && !(from instanceof String)) {
        return NOT_CONVERTABLE;
    }
    PropertyEditor pe = PropertyEditorManager.findEditor(type);
    if (pe == null) {
        return NOT_CONVERTABLE;
    }
    if (from == null) {
        return null;
    } else {
        try {
            pe.setAsText((String) from);
            return pe.getValue();
        } catch (Exception e) {
            log.warn("Can't convert parameter to {}", type.getName(), e);
            return NOT_CONVERTABLE;
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号