[英]In struts, How can I receive null for Boolean?
eg 例如
class TestAction
{
@Getter @Setter
Boolean enabled;// null for both
}
HTML HTML
<input type='radio' name="enabled" value='true'> enabled
<input type='radio' name="enabled" value='false'> disabled
<input type='radio' name="enabled" value='null'> both
<!-- value=null will convert to false -->
How can I pass null for Boolean
? 如何为
Boolean
传递null?
UPDATE UPDATE
Answer is impossible. 答案是不可能的。 I use another way below.
我用下面的另一种方式。
My way to around this. 我绕道而行。
@Data // Generate all setter and getter.
public class UserSearchCondition implements ISearchCondition
{
private String enabled = null;
public Boolean isEnabled()
{
if (Strings.isNullOrEmpty(enabled) || enabled.toLowerCase().equals("null"))
return null;
return Boolean.valueOf(enabled);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.