MyEclipse开发Struts中的form的property的第一个字母只能上小写。。
<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
分享到:
相关推荐
MyEclipse开发Struts2
Myeclipse开发struts+hibernate+spring新手入门---环境配置----项目开发示例 Myeclipse开发struts+hibernate+spring小记 开发前准备工作: 1、下载eclipse3.1版本 下载地址: 2、下载Myeclipse插件 下载地址: 3...
MyEclipse开发Struts+Hibernate应用,图文示例
利用Myeclipse开发struts应用程序
myeclipse开发struts实例------>struts在Myeclipse的使用
MyEclipse开发Struts实例.开发环境的配置等.
利用MyEclipse开发Struts+Hibernate应用
MyEclipse开发Struts的小例子 里面有源码 使用说明的PDF 还有程序的说明
初学者初次学习struts相当好,我第一次学struts就是看这个的,一看就懂,图文教程
利用Myeclipse快速开发struts应用程序
myeclipse和struts配置使用
一个简单的Myeclipse+Struts开发登陆的JSP例子
MyEclipse开发StrutsHibernate集成
MyEclipse 开发 Struts 快速上手 图解
struts2国际化MyEclipse开发struts2国际化MyEclipse开发童叟无欺
Eclipse+MyEclipse开发struts的一个经典的实例
MyEclipse开发Struts2详细图解过程
利用MyEclipse开发Struts+Hibernate应用。一个教程,可以参考一下