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

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

内容简介:翻译自: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


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

查看所有标签

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

Coming of Age in Second Life

Coming of Age in Second Life

Tom Boellstorff / Princeton University Press / 2008-04-21 / USD 29.95

The gap between the virtual and the physical, and its effect on the ideas of personhood and relationships, is the most interesting aspect of Boellstorff's analysis... Boellstorff's portrayal of a virt......一起来看看 《Coming of Age in Second Life》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

URL 编码/解码
URL 编码/解码

URL 编码/解码