MyEclipse开发Struts中的form的property的第一个字母只能上小写。。

MyEclipse开发Struts中的formproperty的第一个字母只能上小写。。
BY: Border
 
<html:form action="/userLogin.do">                     

 PassWord : <html:password property="PassWord"/>

 UserName : <html:text property="userName"/>

<html:submit/><html:cancel/>    
</html:form>


中的property="PassWord"中的第一个字母必须是小写。如果是大写就报错。不过是小写的话就通过。。。

 
這不是程式的問題,也和eclipse無關,而是JavaBean的規格本來就是這樣規定

精華區中[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 才能取到值。

讨论http://www.javaworld.com.tw/jute/post/view?bid=10&id=147373&tpg=1&ppg=1&sty=1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值