Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package example;
import org.apache.commons.beanutils.expression.DefaultResolver;
public class SafeResolver extends DefaultResolver {
@Override
public String next(String expression) {
String property = super.next(expression);
if ("class".equalsIgnoreCase(property)) {
return "";
}
return property;
}
}
package example;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.beanutils.BeanUtilsBean;
public class SafeResolverListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent event) {
SafeResolver resolver = new SafeResolver();
BeanUtilsBean.getInstance().getPropertyUtils().setResolver(resolver);
}
@Override
public void contextDestroyed(ServletContextEvent event) {
}
}
@glad2121
Copy link

glad2121 commented May 13, 2014

describe でエラーになる件、これでどうですか?

public class SafeResolver extends DefaultResolver {

    public String next(String expression) {
        String property = super.next(expression);
        if ("class".equalsIgnoreCase(property)
                && !property.equals(expression)) {
            return "";
        }
        return property;
    }

}

@nakamura-to
Copy link
Author

nakamura-to commented May 14, 2014

この方法、うまく動きそうですね。

@bobbyjam99-zz
Copy link

bobbyjam99-zz commented May 16, 2014

describeを拡張しちゃいました。。。こっちのほうがスマートですね!

@uemuraj
Copy link

uemuraj commented May 30, 2014

describe の件、私は hasNested() もオーバーライドして "class" に対してだけ false を返すようにしてみました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment