-
-
Save nakamura-to/11347570 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
} | |
} |
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;
}
}
この方法、うまく動きそうですね。
describe
を拡張しちゃいました。。。こっちのほうがスマートですね!
describe の件、私は hasNested() もオーバーライドして "class" に対してだけ false を返すようにしてみました。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考
http://qiita.com/kawasima/items/670d2591bc8fea19dc1d#comment-a4a513c6cb338dabcbbc