“价值”的实际含义是什么?在 JSP 中?

发布于 2024-11-06 21:10:12 字数 757 浏览 0 评论 0原文

我最近读了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 表单元素的值吗?) 还有 targetproperty 的作用是什么?

由于我是新手,我不知道上面的代码到底发生了什么。如果有错请帮助我并纠正我?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

oО清风挽发oО 2024-11-13 21:10:12

value 表示将设置为target 的表达式

抵押金额从何而来?

它假设作为参数出现,因为您在代码中通过 url 中的 param.mortgageAmount 使用了它,例如

yourapp/page.jsp?mortgageAmount=someVAlue

用简单的话

值是,并且要评估的表达式将被设置到
target 对象的属性由 property 表示


另请参阅

value represents expression that would be set to the target

Where does the mortgageAmount came from?

it assumed to be coming as param as you have used it in your code by param.mortgageAmount in url like

yourapp/page.jsp?mortgageAmount=someVAlue

In Simlper words

value is and Expression to be evaluated which will be set to
target object's property represented by property


See Also

不知在何时 2024-11-13 21:10:12

param 是一个 JSP 隐式对象。这是一个地图,其条目是页面参数 - 因此任何作为查询字符串中的参数进入的内容,或者(我认为)通过表单发布的内容。

Targetproperty 控制 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 and property govern what the c:set does; it sets the named property on the named target object to the given value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文