[英]No getter method for property
Hi I am trying to use struts to get a bean to my jsp code the bean I am using in my jsp page is: but whenever I run the jsp I am receiving 嗨,我正在尝试使用struts将一个bean放入我的jsp代码中,我在jsp页面中使用的bean是:但是每当我运行jsp时,我都会收到
No getter method for property: "testData.team.type" of bean: "unitForm".
Bean:“ unitForm”的属性:“ testData.team.type”没有获取方法。
I am trying to write baseball to my JSP page. 我正在尝试将棒球写到我的JSP页面。
The code for my action form is: 我的操作表单的代码是:
import com.TestGettingData;
import org.apache.struts.action.ActionForm;
public class UnitForm extends ActionForm {
private TestGettingData testData = new TestGettingData();
public TestGettingData getTestData() {
return testData;
}
public void setTestData(TestGettingData testData) {
this.testData = testData;
}
}
testing data class has: 测试数据类具有:
public class TestGettingData extends Sport{
private String team = "Yankees";
private String position = "short stop";
public void setTeam(String tm) {
team = tm; }
public String getTeam() {
return team; }
public void setPosition(String po) {
position = po; }
public String getPosition() {
return position;
}
}
and finally in my sport class: 最后是我的体育课:
public class Sport{
public String type = "baseball";
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
Instead of testData.team.type
, try testData.type
. 取而代之的
testData.team.type
,尝试testData.type
。 type
is a property in testData
not in team
. type
是testData
中的属性,不在team
。
Update 更新资料
${unitForm.testData.type}
should display "baseball" in your JSP. ${unitForm.testData.type}
应该在您的JSP中显示“棒球”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.