简体   繁体   English

jsp支柱; 如何设置formbean属性是基于另一个form bean属性

[英]jsp struts ; how to set formbean attribute is based on another form bean attribute

I am working on a web app using JSP with struts 1.2 I have a requirement where i need to set a display a field on UI . 我正在使用在Struts 1.2上使用JSP的Web应用程序,但我有一个需要在UI上设置显示字段的要求。 the field value formbean attribute is based on another form bean attribute. 字段值formbean属性基于另一个form bean属性。 I added a if check, but not sure how to set the attribute. 我添加了if检查,但不确定如何设置属性。

<c:when test="${person.relationship == SA || person.relationship == SP }">
//how to set person.status = married;
</c:when>

person is formbean and relationship and status are attributes. 人是formbean,关系和状态是属性。

You can set like, 您可以设置为

<c:when test="${person.relationship == SA || person.relationship == SP }">
    <html:text value="<%= status %>" property="person.status" size="25" maxlength="256"></html:text>
</c:when>

Here "status" is the run time variable derived from "form bean" or you can give some hard coded string as well. 这里的“状态”是派生自“ form bean”的运行时变量,或者您也可以给出一些硬编码的字符串。

You can use any UI element based on your requirement. 您可以根据需要使用任何UI元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM