在Java中将Bean Class变量用于Jsp(UI层) [英] Using Bean Class variable into the Jsp (UI layer) in java

查看:115
本文介绍了在Java中将Bean Class变量用于Jsp(UI层)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在struts1框架中使用"if条件和while循环".我有一个带有setter()和getter()方法的Bean类,用于fname和lname属性.如何在jsp中使用该bean变量检查条件?如何检查条件?

I want to use "if condition and while loop" in struts1 framework. I have a Bean class with setter() and getter() methods for fname and lname property. How to use that bean variable in jsp for checking if condition? How to check if condition?

例如:

if (firstname==lastname)
    { some action... }

推荐答案

要执行测试和循环,可以使用

To perform tests and loops you can use the Struts logic tags. What you are looking for are the <logic:equal> and <logic:iterate> tags. These work easily if you want to test or loop over properties of action form beans, thanks to their property attribute.

您还可以使用 <c:if> <c:forEach> 标签. developer.com/java/ejb/article.php/1447551/An-Introduction-to-JSP-Standard-Template-Library-JSTL.htm"rel =" nofollow noreferrer> JSTL 用于此类操作(这些是不依赖Struts的通用标签.

You could also use the <c:if> and <c:forEach> tags of JSTL for operations like these (these are generic tags that don’t depend on Struts).

这篇关于在Java中将Bean Class变量用于Jsp(UI层)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆