“价值”的实际含义是什么?在 JSP 中?
我最近读了JSP,并对它使用的javabeans技术有疑问。让我们说下面的 JavaBeans 代码:
package mortgage;
public class Mortgage
{
private double amount = -1.0;
public void setAmount(double amount)
{
this.amount = amount;
}
}
假设我必须在 JSP 中使用这个 JavaBeans 并获取从 HTML 表单或 URL 查询字符串和 JSP 代码中获取的参数值,如下所示:
<jsp:useBean id="calc" class="mortgage.Mortgage" />
<p> Testing . . .
<c:set target="${calc}" property="amount" value="${param.mortgageAmount}" />
. . . . .
这个示例几乎没有修改我的书。我的问题是上面代码 JSP 中的这个 value
是做什么的? mortgageAmount
来自哪里?(这是来自 HTML 表单元素的值吗?) 还有 target
和 property
的作用是什么?
由于我是新手,我不知道上面的代码到底发生了什么。如果有错请帮助我并纠正我?
I have read JSP recently, and have a doubt in the javabeans technolgy it uses. Lets say that the following JavaBeans code :
package mortgage;
public class Mortgage
{
private double amount = -1.0;
public void setAmount(double amount)
{
this.amount = amount;
}
}
And lets say i have to make use of this JavaBeans in my JSP and take the parameter values obtain from the HTML form or from the URL query string and JSP code as follows:
<jsp:useBean id="calc" class="mortgage.Mortgage" />
<p> Testing . . .
<c:set target="${calc}" property="amount" value="${param.mortgageAmount}" />
. . . . .
This example was little modified from my book. My question is what does this value
in the above code JSP does? Where does the mortgageAmount
came from?(is this the value from the HTML form element?)
And also what does target
and property
does?
Since I am a novice, i dont know what actually is going on the above code. Please help me and correct me if am wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
value
表示将设置为target
的表达式它假设作为参数出现,因为您在代码中通过 url 中的
param.mortgageAmount
使用了它,例如用简单的话
值是,并且要评估的表达式将被设置到
target
对象的属性由property
表示另请参阅
value
represents expression that would be set to thetarget
it assumed to be coming as param as you have used it in your code by
param.mortgageAmount
in url likeIn Simlper words
value is and Expression to be evaluated which will be set to
target
object's property represented byproperty
See Also
param
是一个 JSP 隐式对象。这是一个地图,其条目是页面参数 - 因此任何作为查询字符串中的参数进入的内容,或者(我认为)通过表单发布的内容。Target
和property
控制c:set
的作用;它将指定目标对象上的指定属性设置为给定值。param
is a JSP implicit object. It's a map whose entries are the page parameters - so anything that's come in as a parameter in the query string, or (i think) through a form post.Target
andproperty
govern what thec:set
does; it sets the named property on the named target object to the given value.