gpt4 book ai didi

java.lang.ClassCastException : java. lang.Boolean 无法转换为 Struts 逻辑中的 java.lang.String:equal 标记

转载 作者:行者123 更新时间:2023-12-05 07:41:22 24 4
gpt4 key购买 nike

当我想访问我的 JSP 页面时出现错误。

我的 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";
}
}
...
}

错误:

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:

https://pastebin.com/QmgtXBqA

...
<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){
...
}
}
....

怎么了?

最佳答案

错误是因为您将 boolean 值作为参数传递给 isFilledChildren 属性

<logic:equal name="sub/dir/detail" property="bean.enfant.isFilledChildren" value="true">

在您的 bean 中,该属性接受字符串值

关于java.lang.ClassCastException : java. lang.Boolean 无法转换为 Struts 逻辑中的 java.lang.String:equal 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45367172/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com