Myeclipse8.5
提示这个错误,我搞不明白。请大侠帮忙Can't find a method to write property 'name' of type 'java.lang.String' in a bean of type 'part4.Student'package part4;public class Student 
{
public String name=null;
public long number;
public double height,weight;
public String getName()
{
return name;
}
public void SetName(String name)
{
this.name=name;
}
public long getNumber()
{
return number;
}
public void SetHeight(double height)
{
this.height=height;
}
public double getHeight()
{
return height;
}
public void setWeight(double weight)
{
this.weight=weight;
}
public double getWeight()
{
return weight;
}
}
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="part4.Student" %>
<HTML>
  <body bgcolor=pink>
    <font size=4>
      <jsp:useBean id="zhao" class="part4.Student" scope="page"/>
      <jsp:setProperty property="name" name="zhao" value="赵峰"/>
      名字是:<jsp:getProperty property="name" name="zhao"/>
      <jsp:setProperty property="number" name="zhao" value="001"/>
      <BR>学号是:<jsp:getProperty property="number" name="zhao"/>
      <jsp:setProperty property="weight" name="zhao" value="60"/>
      <BR>体重是:<jsp:getProperty name="zhao" property="weight" />
      <jsp:setProperty property="height" name="zhao" value="<%=175%>"/>
      <BR>身高是:<jsp:getProperty property="weight" name="zhao"/>
    </font>
  </body>
</HTML>

解决方案 »

  1.   

    可能是name作为关键字,太常用了吧,
    在这里 <jsp:setProperty property="name" name="zhao" value="赵峰"/>
    编译器可能会误解为其他的用处,换一个试试看
      

  2.   

    感觉这行可以不要:
    <%@ page import="part4.Student" %>
    确保你的\part4是在tomcat\webapps\youweb\WEB-INF\CLASS目录下
      

  3.   

    javabean中应该将属性字段定义为private的,get/set方法定义为public的
    可能是这个问题导致的
      

  4.   

    这个我是因为错,才把那改为public的
      

  5.   

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

  6.   

    name 这个变量换成别的试过没?可能和系统中一些标识重复导致的错误,
      

  7.   

    name 这个变量换成别的试试
      

  8.   

    不是这个原因,是javabean的规范。
    要是问题解决了,结贴,给分
      

  9.   

    Can't find a method to write property 'name' of type
    提示说的很清楚啦,不能找到这个方法去写入name这个属性,那就是说你的set方法有问题
    这个方法要按照规范来,不然内部映射找不到