Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp Can';找不到写入属性的方法';id';类型为';java.lang.Integer';在类型为'的bean中';package.myBean“;_Jsp_Javabeans_Jsp Tags - Fatal编程技术网

Jsp Can';找不到写入属性的方法';id';类型为';java.lang.Integer';在类型为'的bean中';package.myBean“;

Jsp Can';找不到写入属性的方法';id';类型为';java.lang.Integer';在类型为'的bean中';package.myBean“;,jsp,javabeans,jsp-tags,Jsp,Javabeans,Jsp Tags,我使用jsp和JavaBean将表单元素插入到数据库表中。然而,每次我尝试使用标记设置JavaBean的integer属性时,都会出现上述错误。同时,它正在处理bean的字符串属性 如果我使用 每次将deptId值设置为0时,setProperty只能获取字符串值 试试这个 <jsp:setProperty name="newEmp" property="deptId" value="deptId" /> 在bean中,可以有setter-getter,它将deptID

我使用jsp和JavaBean将表单元素插入到数据库表中。然而,每次我尝试使用标记设置JavaBean的integer属性时,都会出现上述错误。同时,它正在处理bean的字符串属性


如果我使用



每次将deptId值设置为0时,setProperty只能获取字符串值

试试这个

<jsp:setProperty name="newEmp" property="deptId" value="deptId" />


在bean中,可以有setter-getter,它将deptID作为字符串。。当您要在数据库中插入时解析它们

检查bean类是否省略了setter方法, 整数变量在下面的示例代码中是ok的:

public int getDeptId() {
        return deptId;
    }


public class Produce {
    private String name="电吉他";
    private double price=1880.5;
    private int count=100;
    private String factoryAdd="吉林省长春市";

    public double getPrice() {
        return price;
    }

    public String getFactoryAdd() {
        return factoryAdd;
    }

    public String getName() {
        return name;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCount() {
        return count;
    }
}


<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>Title</title>
</head>
<body>
<jsp:useBean id="produce" class="net.cs30.Produce"></jsp:useBean>
<jsp:setProperty name="produce" property="name" value="洗衣机"/>
<jsp:setProperty name="produce" property="count" value="12306"/>
<div>
    <ul>
        <li>商品名称:<jsp:getProperty name="produce" property="name"></jsp:getProperty></li>
        <li>厂址:<jsp:getProperty name="produce" property="count"/></li>
    </ul>
</div>
</body>
</html>
public int getDeptId(){
返回deptId;
}
公营产品{
专用字符串名称=”电吉他";
私人双价=1880.5;
私有整数计数=100;
专用字符串factoryAdd=”吉林省长春市";
公开双价{
退货价格;
}
公共字符串getFactoryAdd(){
返回工厂添加;
}
公共字符串getName(){
返回名称;
}
公共无效集合计数(整数计数){
this.count=计数;
}
公共void集合名(字符串名){
this.name=名称;
}
public int getCount(){
返回计数;
}
}
标题
  • 商品名称:
  • 厂址:
这是我输出的一个示例。


<jsp:setProperty name="newEmp" property="deptId" value="deptId" />

检查bean的setter方法中传递的参数是否应该在datatypeint中。如果它在Integer中,它将不起作用。

你能分享你的代码吗?请附上其他代码片段(例如bean)bean有成员String name、String address、String gender和Integer deptId。我可以使用jsp:setProperties设置name、address和gender的值,但它不适用于deptId