<s:property value="#map['a']"/> ---------->正确,因为其支持char
${map['a']} ------------>错误, 因为'a'在jsp el表达式中是字符串,不能=char。
<s:property value='#map = #{"a":123, "b":234}, ""'/> --->此时key是字符串
${map['a']}
补充:
在EL表达式规范2.2中,定义了:
写道
■ The value of an IntegerLiteral ranges from Long.MIN_VALUE to
Long.MAX_VALUE
■ The value of a FloatingPointLiteral ranges from Double.MIN_VALUE to
Double.MAX_VALUE
在tomcat7.0.6实现中,jasper.jar(实现了EL2.2规范):
AstFloatingPoint表示小数,AstInteger表示整数,其定义如下:
Java代码 public final class AstInteger extends SimpleNode
{
private volatile Number number;
public AstInteger(int id)
{
super(id);
}
protected Number getInteger()
{
if (this.number == null) {
try {
this.number = new Long(this.image);
} catch (ArithmeticException e1) {
this.number = new BigInteger(this.image);
}
}
return this.number;
}
public Class<?> getType(EvaluationContext ctx)
throws ELException
{
return getInteger().getClass();
}
public Object getValue(EvaluationContext ctx)
throws ELException
{
return getInteger();
}
}
Java代码 public final class AstFloatingPoint extends SimpleNode
{
private volatile Number number;
public AstFloatingPoint(int id)
{
super(id);
}
public Number getFloatingPoint()
{
if (this.number == null) {
try {
this.number = new Double(this.image);
} catch (ArithmeticException e0) {
this.number = new BigDecimal(this.image);
}
}
return this.number;
}
public Object getValue(EvaluationContext ctx)
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-31948-2.html
自由航行是指商船而不是军舰