I have an error when iwant to acces to my jsp page . My bean:
public class BeChildren implements Serializable
{
...
private String isFilledChildren;
....
/**
* @param isFilledChildrenthe isFilledChildrento set
*/
public void setIsFilledChildren( String isFilledChildren)
{
this.isFilledChildren= isFilledChildren;
}
public String getIsFilledChildren( )
{
if ( getNom( ) != null )
{
return "true";
} else
{
return "false";
}
}
...
}
Error:
28/07/17-09:13:10,670 ERROR org.apache.struts.taglib.tiles.InsertTag - ServletException in '/pages/sub/dir/detail/body.jsp': javax.servlet.jsp.JspException: Invalid argument looking up property: "bean.enfant.isFilledChildren" of bean: "sub/dir/detail"
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Invalid argument looking up property: "bean.enfant.isFilledChildren" of bean: "sub/dir/detail"
javax.servlet.jsp.JspException: Invalid argument looking up property: "bean.children.isFilledChildren" of bean: "sub/dir/detail"
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
My JSP:
...
<html:form action="/page/sub/dir/detail.do">
<html:hidden name="sub/dir/detail" property="modeCreation" styleId="modeCreation"/>
<html:hidden name="sub/dir/detail" property="bean.enfant.isFilledChildren"/>
....
<logic:equal name="sub/dir/detail" property="bean.enfant.isFilledChildren" value="true">
.....
</logic:equal>
...
<script language="javascript" type="text/javascript">
var f = document.forms[0];
function init(){
var isFilledChildren = document.forms[0].elements["bean.enfant.isFilledChildren"];
....
if (isFilledChildren!=null && "true"==isFilledChildren.value){
...
}
}
....
What is wrong ?
字符串类型的属性应使用字符串值来避免ClassCastException
。
<logic:equal name="sub/dir/detail" property="bean.enfant.isFilledChildren" value="'true'">
The error is ecause you pass boolean value to isFilledChildren property as parameter
<logic:equal name="sub/dir/detail" property="bean.enfant.isFilledChildren" value="true">
In your bean the property accepts String value
Changing the type for isFilledChildren property to String would resolve this.
If it does not, try with <logic:match />
and <logic:notMatch />
(if it's feasible in this use case). See below for logic:match sample code"
<logic:match name="UserForm" property="favouriteFood" value="Pizza">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.