Why JSTL number format value does not support runt

2020-04-07 20:06发布

I have this code:

<fmt:formatNumber type="number" 
                  maxFractionDigits="2" 
                  value="${maxAllowableAmount}" />

I have this warning in Eclipse editor:

"value" does not support runtime expressions

I tried to ignore it and run the app, but I have this runtime error:

quote symbol expected

How am I gonna deal with this?

My data comes from the database and I want to format it on my browser.

标签: java jsp jstl
4条回答
Anthone
2楼-- · 2020-04-07 20:20

That's a bit peculiar. If I understand the taglib javadoc correctly, the type attribute can be a runtime value.

Perhaps you are using an older version of JSTL that doesn't support RT/EL? Check what namespace is associated with the 'fmt' prefix in your JSP.

查看更多
别忘想泡老子
3楼-- · 2020-04-07 20:24

You're using the prehistoric JSTL 1.0 version (or even a prototype). You need to upgrade to at least JSTL 1.1, or if your container supports it (Servlet 2.5 or newer), upgrade to currently latest JSTL 1.2.

You can find JSTL download links in our JSTL wiki page. Don't forget to remove the old JSTL libraries (jstl.jar and standard.jar) and to fix the @taglib declarations to include the /jsp path. Also ensure that your web.xml is declared conform at least Servlet 2.4 for JSTL 1.1 or as at least Servlet 2.5 for JSTL 1.2.

查看更多
Summer. ? 凉城
4楼-- · 2020-04-07 20:24
够拽才男人
5楼-- · 2020-04-07 20:42

Ensure that you are using the correct @ taglib directive. Replace:

<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>

with:

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

The /jsp makes the difference.

查看更多
登录 后发表回答