简体   繁体   中英

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

No getter method for property: "testData.team.type" of bean: "unitForm".

I am trying to write baseball to my JSP page.

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 . type is a property in testData not in team .

Update

${unitForm.testData.type} should display "baseball" in your JSP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM