Struts2 submits a request using form or js to encapsulate the Boolean value.
On JSPCode
<Form name = "searchform" Action = "">
<Input id = "searchinfo. ishighsearch" name = "searchinfo. ishighsearch" value = "true"
Type = "hidden"/>
Then, use struts2 to encapsulate parameters in Vo bean. The Bean class name is searchinfo. java.
This class has attributes.
Private Boolean ishighsearch;
The Set/get method automatically generated with myeclipse 6.0 is
The corresponding set/get method is
Public Boolean ishighsearch (){
Return ishighsearch;
}
Public void sethighsearch (Boolean ishighsearch ){
This. ishighsearch = ishighsearch;
}
Then in the action
Searchinfobean = new searchinfobean ();
System. Out. println (searchinfobean. ishighsearch ());
The printed value is always false, which is inconsistent with the form value.
Later, we found that the get method automatically generated by myelipse, which belongs to the boolean type, is automatically prefixed with "is" in the attribute name ",
The above example is ishighsearch,
The solution is to change the attribute name to highsearch, remove the preceding is, and then obtain the value of highsearch correctly.
Modify the JSP page
<Input id = "searchinfo. highsearch" name = "searchinfo. highsearch" value = "true" type = "hidden"/>
Change the Bean class attribute
Private Boolean highsearch;
Public Boolean ishighsearch (){
Return highsearch;
}
Public void sethighsearch (Boolean highsearch ){
This. highsearch = highsearch;
}
To sum up, the attribute name of the JavaBean object. If it is a Boolean attribute, it cannot start with "is". This will avoid unnecessary issues.
Error