日期:2014-05-19  浏览次数:20670 次

Cannot find bean strName in any scope

这个是jsp中的代码
Java code
<body>
    Hello World!
<p>UserName:</p><html:text property="strName" name="strName"  />
<p>Password:</p><html:text property="strPwd" name="strPwd"/>
</body>



这个是配置文件中的信息
XML code
     <form-beans >
         <form-bean name="myFrom" type="com.myFrom"></form-bean>
     </form-beans>

    <action-mappings>
        <action path="/com/myjsp"
                 name="myFrom"
                 parameter="method"
                 type="com.myjspAction"
                 validate="false"
                 scope="request"
                 >
            <forward name="success" path="/resources/mytest.jsp" />

        </action>
    </action-mappings>

Java code

public class myFrom extends ActionForm {
    private  String strName="";
    private  int age;

    public String getStrPwd() {
        return strPwd;
    }

    public void setStrPwd(String strPwd) {
        this.strPwd = strPwd;
    }

    private  String strPwd="";

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    private  int weight;

    public String getStrName() {
        return strName;
    }

    public void setStrName(String strName) {
        this.strName = strName;
    }
}



为什么 还会报 Cannot find bean strName in any scope错误呢??

------解决方案--------------------
<body>
Hello World!
<p>UserName:</p><html:text property="strName" name="myFrom" />
<p>Password:</p><html:text property="strPwd" name="myFrom"/>
</body>