當我想訪問我的jsp頁面時出現錯誤。 我的豆:java.lang.ClassCastException:java.lang.Boolean不能在Struts邏輯中強制轉換爲java.lang.String:等於標記
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";
}
}
...
}
錯誤:
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
我的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){
...
}
}
....
出了什麼問題?
@Mercer你可以理解我們可以檢查所有代碼你可以只貼上的你PROGRAMM說,有問題的代碼,我不認爲這是!難以理解 –
你看到類拋出異常嗎?似乎是你的JSP期望的數據類型布爾值,而不是字符串 –
@MichaelMeyer我看到,但我沒有布爾數據類型 – Mercer