ModelDriven returns NULL for the params which have empty values.
Bean:
public class MyBean
{
private String userName;
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserName()
{
return userName;
}
}
Class:
public class MyAction extends ActionSupport implements ModelDriven<MyBean>
{
MyBean myBean = new MyBean();
public String execute()
{
System.out.println(myBean.getUserName());//getting null here
return "SUCCESS";
}
}
Request:
/home/MyAction.do?userName=&pass=
Hear I am passing empty value for userName param but in action I getting the null value.
How to get exact value in ModelDriven?
When your bean property contains a
nullvalue it keeps the value in the OGNL expressions andvaluetag. You can always use OGNL expression to evaluatenullvalue. For exampleIf you want to pass
nullvalue as a parameter then you should usenullstring.