<html:form action="/userLogin.do">
PassWord : <html:password property="PassWord"/> UserName : <html:text property="userName"/>
<html:submit/><html:cancel/>
</html:form>
|
中的property="PassWord"中的第一个字母必须是小写。如果是大写就报错。不过是小写的话就通过。。。
精華區中[JSTL1.1中的JavaBean取值問題] , 在JavaBeans spec 8.8 有說明,
節錄於下:
When we use design patterns to infer a property name, we need to decide whatrulesto follow for capitalizing the inferred name. If we extract the name from the middle of a normal mixedCase style Java name then the name will, by default, begin with a capital letter.
Java programmers are accustomed to having normal identifiers start with
lower case letters.Vigorous reviewer input has convinced us that we should follow this sameconventional rule
for property names.
Thus when we extract a property name from the middle of an existing Javaname, we normally convert the first character to lower case.
However to support the occasionaluse of all upper-case names, we check if the first two characters of the name are both upper case and if so leave it alone. So for example,
"FooBah" becomes "fooBah"
"Z" becomes "z"
"URL" becomes "URL"
=============================================
也就是說,因為您的METHOD是 getM_ACCOUNT, 第二個字被判定是小寫(_),所以properties會被認為轉為m_ACCOUNT, 又, ID兩個都是大寫, 所以不必改為 iD. 這種判定也會發生在數字,中文等字元上. 所以如果是getC1ABC,則JavaBean properties會被認為是c1ABC
struts-html 標籤使用 org.apache.struts.taglib.html.BEAN 這個JavaBean的 getPassWord() 來取得PassWord的值,所以 property 要給定 passWord 才能取到值。