jsp:setproperty property ="*"不能设置所有属性 [英] jsp:setproperty property=“*” not set all properties
问题描述
我有包含以下内容的jsp页面
i have jsp page which contains
<jsp:useBean id="RcvMsgTransferTanseekBean" class= "com.test.RcvMsgTransferTanseekBean" />
<jsp:setProperty name="RcvMsgTransferTanseekBean" property="*" />
和其中包含的豆子
private String nId = "";
public void setNId (String value){
this.nId = value;
}
public String getNId(){
return this.nId;
}
我向该jsp页面发送请求
i send request to that jsp page
test.jsp?letId=479438&dstId=522375&nId=138393&subject=66666666666&letForInfo=1&shNotMan=true
我的问题是只有nId参数仍然为空.
my problem is that the nId parameter only is still empty.
当我在jsp中添加新行时
when i added new line in the jsp
<jsp:setProperty name="RcvMsgTransferTanseekBean" property="nId" />
它工作正常,为什么'property ="*"'不能像预期的那样工作?
it works fine, why the 'property="*"' didn't work as the supposed to be ?
推荐答案
问题出在属性名称上.
CamelCase的大写字母和大写字母不起作用,就像您期望的单个前导字母一样.
为了设置属性的值,使用了setter方法.
而nId
的设置者是setNId
.
The issue is in the name of the property.
The Capitalization and Decapitalization of the CamelCase don't work as you expect for single leading letter.
For Setting the value of the property the setter method are used.
And the setter for nId
is setNId
.
8.8推断名称的大写.
8.8 Capitalization of inferred names.
当我们使用设计模式来推断属性或事件名称时,我们需要 决定要遵循的规则将大写的名称大写.如果 我们从普通的MixedCase样式Java的中间提取名称 名称,然后默认情况下,名称将以大写字母开头.爪哇 程序员习惯于以普通标识符开头 小写字母.审稿人的大力投入使我们深信 对于财产和事件应遵循相同的常规规则 名称.
When we use design patterns to infer a property or event name, we need to decide what rules to 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 same conventional rule for property and event names.
因此,当我们从中间位置提取属性或事件名称时 现有的Java名称,我们通常将第一个字符转换为小写 案子.但是,为了支持偶尔使用所有大写名称, 我们检查名称的前两个字符是否都大写 如果可以的话,请不要管它.例如,
Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to lower case. However to support the occasional use 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"变成"fooBah""Z"变成"z""URL"变成"URL"
"FooBah" becomes "fooBah" "Z" becomes "z" "URL" becomes "URL"
我们提供了Introspector.decapitalize方法来实现 转换规则.
We provide a method Introspector.decapitalize which implements this conversion rule.