java – 在JSP中,如何识别List中存在的Object类型?

栏目: Java · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/1072772/in-jsp-how-to-identify-the-type-of-object-present-in-a-list
在JSP中是否有可能获得List中的Object类型,就像我们在 Java

中一样

myDataBind.getResultsList().get(0).getClass();

或者是否有可能实现这样的目标:

if ( myDataBind.getResultsList().get(0) instanceOf MyClass ) {
  doThis;
}

我不喜欢scriptlet,但如果没有scriptlet就不可能,那么请告诉我即使是这个解决方案.

>假设列表中的所有对象都是相同的类型.

使用JSTL,您可以检索使用JavaBean规范的所有内容 – 如果要在 java 中使用getClass(),则可以在JSTL中使用.class:

这会写出你的类名:

${myList[0].class}

翻译自:https://stackoverflow.com/questions/1072772/in-jsp-how-to-identify-the-type-of-object-present-in-a-list


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Out of Control

Out of Control

Kevin Kelly / Basic Books / 1995-4-14 / USD 22.95

Out of Control is a summary of what we know about self-sustaining systems, both living ones such as a tropical wetland, or an artificial one, such as a computer simulation of our planet. The last chap......一起来看看 《Out of Control》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具