jstl

Showing the current date using JSTL formatDate tag

十年热恋 提交于 2019-12-30 16:28:32
问题 I am trying to show the current date in my JSP page using JSTL. below is the code I am using. <jsp:useBean id="now" class="java.util.Date" scope="request" /> <fmt:formatDate value="${now}" pattern="MM.dd.yyyy" /> But the above code is not producing any results? Am I missing anything here or is there any better approach for this? I am using JSTL 1.1. 回答1: Try to print it without formatting, ${now}, you probably have null in there. Do you have this attribute in request scope? Just double check,

Why is jstl's formatNumber currency symbol locale specific when setting currencyCode

与世无争的帅哥 提交于 2019-12-30 10:59:47
问题 I'm using formatNumber as follows: <fmt:formatNumber value="${amount}" type="currency" currencyCode="${currencyCode}" var="amt" /> If I'm in locale en_US and the currency code is EUR I get EUR as the symbol, but if I'm in locale en_GB I get € . Why is the locale taken into account? Shouldn't EUR always convert into € ? Is there anyway to get the behavior I'm expecting using formatNumber ? 回答1: Locale is taken into acount so the output makes sense to the user. As a silly American (who lives in

Why is jstl's formatNumber currency symbol locale specific when setting currencyCode

时光毁灭记忆、已成空白 提交于 2019-12-30 10:59:12
问题 I'm using formatNumber as follows: <fmt:formatNumber value="${amount}" type="currency" currencyCode="${currencyCode}" var="amt" /> If I'm in locale en_US and the currency code is EUR I get EUR as the symbol, but if I'm in locale en_GB I get € . Why is the locale taken into account? Shouldn't EUR always convert into € ? Is there anyway to get the behavior I'm expecting using formatNumber ? 回答1: Locale is taken into acount so the output makes sense to the user. As a silly American (who lives in

iterating of muliple items in jstl

坚强是说给别人听的谎言 提交于 2019-12-30 05:31:04
问题 I have this requirement to iterate over 3 lists at the same time in jstl. for iterating over a single list we use <c:forEach var = "mfgn" items = "${requestScope.mfgNumber}" varStatus = "status"> do something; </c:forEach> I need to do some thing like <c:forEach var = "mfgn" var = "issue" items = "${requestScope.mfgNumber}" items = "${requestScope.something" varStatus = "status"> mfgNumber; </c:forEach> is this possible or there an otherway to iterate over multiple lists at the same time. 回答1

jstl fmt功能说明

梦想的初衷 提交于 2019-12-30 05:20:00
所有标签: Tags fmt:requestEncoding fmt:setLocale fmt:timeZone fmt:setTimeZone fmt:bundle fmt:setBundle fmt:message fmt:param fmt:formatNumber fmt:parseNumber fmt:formatDate fmt:parseDate <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> jstl fmt 函数大全 主要功能格式化 日期格式 (2008年5月5日22点00分23秒) <fmt:formatDate value="<%=new Date() %>" pattern="yyyy年MM月dd日HH点mm分ss秒" /> 保留两位小数 <fmt:formatNumber value="123.123456789" pattern="0.00"/> 格式数字 ( 45,678.234 ) <fmt:formatNumber type="number" value="45678.2345" /> 格式百分比 (23%) <fmt:formatNumber type="percent" value="0.2345" /> 其他 <fmt:bundle>:资源绑定

fmt jstl标签 时间格式化例子

梦想的初衷 提交于 2019-12-30 05:13:35
所有标签: Tags fmt:requestEncoding fmt:setLocale fmt:timeZone fmt:setTimeZone fmt:bundle fmt:setBundle fmt:message fmt:param fmt:formatNumber fmt:parseNumber fmt:formatDate fmt:parseDate <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> jstl fmt 函数大全 主要功能格式化 日期格式 (2008年5月5日22点00分23秒) <fmt:formatDate value="<%=new Date() %>" pattern="yyyy年MM月dd日HH点mm分ss秒" /> 保留两位小数 <fmt:formatNumber value="123.123456789" pattern="0.00"/> 格式数字 ( 45,678.234 ) <fmt:formatNumber type="number" value="45678.2345" /> 格式百分比 (23%) <fmt:formatNumber type="percent" value="0.2345" /> 其他 <fmt:bundle>:资源绑定

JSTL foreach: get Next object

 ̄綄美尐妖づ 提交于 2019-12-30 03:15:13
问题 I need display product in list into 3 columns with foreach . Here is my code: <table> <c:forEach items="${lstProduct}" var="product" varStatus="status" step="3"> <tr> <td> <!--product of column left will be display here --> ${product.id} ${product.name} </td> <td> <!--product of column middle will be display here --> <!--I need something like this: productMiddle = product.getNext() --> </td> <td> <!--product of column right will be display here --> <!-- productRight = productMiddle.getNext()

Alternative to using c:out to prevent XSS

北城以北 提交于 2019-12-30 03:15:06
问题 I'm working on preventing cross site scripting (XSS) in a Java, Spring based, Web application. I have already implemented a servlet filter similar to this example http://greatwebguy.com/programming/java/simple-cross-site-scripting-xss-servlet-filter/ which sanitizes all the input into the application. As an extra security measure I would like to also sanitize all output of the application in all JSPs. I have done some research to see how this could be done and found two complementary options.

How to use both single and double quotes inside JSTL/EL expression?

偶尔善良 提交于 2019-12-29 08:45:12
问题 I want to call fn:replace inside EL inside c:out to replace quote caracters. The following does not work <c:out value="${fn:replace(userName,'"','\\"')}"/> because XML parser stops at first double quote and sees no c:cout tag termination (JSP compilation stage error). The following <c:out value="${fn:replace(userName,'"','\\"')}"/> does not work, probably because replace function does not see actual quote character. 回答1: Parameterize them with <c:set> . <c:set var="search" value='"' /> <c:set

Add values to arraylist use JSTL

佐手、 提交于 2019-12-29 07:50:13
问题 is it possible to add values to an ArrayList instead of using a HashMap something like: <jsp:useBean id="animalList" class="java.util.ArrayList" /> <c:set target="${animalList}" value="Sylvester"/> <c:set target="${animalList}" value="Goofy"/> <c:set target="${animalList}" value="Mickey"/> <c:forEach items="${animalList}" var="animal"> ${animal}<br> </c:forEach> now getting the error: javax.servlet.jsp.JspTagException: Invalid property in <set>: "null" thx 回答1: JSTL is not designed to do this