<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
不适用于 glassfish 4 和 wildfly 8 Final 上的最新 Mojarra 2.2.5
我已经看到了关于此的多个错误报告,Manfried Riem says ,
It was determined this is an EL issue and the EL implementation has been fixed to fix this
修复版本显示为 2.2.5,并且在 2.2.5 的发行说明中也有说明,我是否遗漏了什么?
最佳答案
使用自定义解析器修复:
faces-config.xml:
<application>
<el-resolver>my.package.EmptyNullStringResolver</el-resolver>
</application>
EmptyNullStringResolver.java:
/**
* @author pg
*/
public class EmptyNullStringResolver extends ELResolver {
@Override
public Class<?> getCommonPropertyType(ELContext context, Object base) {
return String.class;
}
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
return null;
}
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
return null;
}
@Override
public Object getValue(ELContext context, Object base, Object property) {
return null;
}
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
return true;
}
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
}
@Override
public Object convertToType(ELContext context, Object obj, Class<?> targetType) {
if (String.class.equals(targetType) && obj instanceof String && ((String) obj).trim().isEmpty()) {
context.setPropertyResolved(true);
}
return null;
}
}
关于jsf - javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL 自 Java EE 7/EL 3.0 起不再工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21880017/